{"id":627,"date":"2026-07-23T00:54:36","date_gmt":"2026-07-22T16:54:36","guid":{"rendered":"https:\/\/cococat.top\/?p=627"},"modified":"2026-07-23T00:54:36","modified_gmt":"2026-07-22T16:54:36","slug":"claude-code-%e7%ac%94%e8%ae%b0-1%ef%bc%9amid-conversation-system-message","status":"publish","type":"post","link":"https:\/\/cococat.top\/index.php\/2026\/07\/23\/claude-code-%e7%ac%94%e8%ae%b0-1%ef%bc%9amid-conversation-system-message\/","title":{"rendered":"Claude Code \u7b14\u8bb0 1\uff1amid-conversation system message"},"content":{"rendered":"<p>\u6765\u6e90\uff1a<br \/>\n<a href=\"https:\/\/platform.claude.com\/docs\/en\/build-with-claude\/mid-conversation-system-messages\">https:\/\/platform.claude.com\/docs\/en\/build-with-claude\/mid-conversation-system-messages<\/a><\/p>\n<h1>1. \u80cc\u666f<\/h1>\n<p>\u5bf9\u4e8e cc \u62fc\u63a5\u7684\u5b8c\u6574 prompt\uff0c\u7cfb\u7edf\u6307\u4ee4\uff08system message\uff09\u901a\u5e38\u653e\u5728\u6700\u524d\u9762\uff0c\u5373\u5728\u6240\u6709\u5bf9\u8bdd\u6d88\u606f\u4e4b\u524d\uff0c\u662f\u6574\u4e2a prompt \u7684\u5f00\u5934\u3002<\/p>\n<p>\u800c\u63d0\u793a\u8bcd\u7f13\u5b58\u547d\u4e2d\u7684\u524d\u63d0\u662f\uff0c\u8bf7\u6c42\u7684\u524d\u7f00\u5fc5\u987b\u548c\u4e4b\u524d\u7684\u8bf7\u6c42\u9010\u5b57\u8282\u5b8c\u5168\u4e00\u81f4\u3002<\/p>\n<p>\u6240\u4ee5\u5728\u4f20\u7edf\u65b9\u6848\u91cc\uff0c\u4e00\u65e6\u9700\u8981\u518d\u5bf9\u8bdd\u4e2d\u9014\u4fee\u6539\u7cfb\u7edf\u6307\u4ee4\uff0c\u5219\u4f1a\u5bfc\u81f4\u7f13\u5b58\u5b8c\u5168 miss\u3002<\/p>\n<h1>2. \u65b9\u6848<\/h1>\n<p>\u505a\u6cd5\u5f88\u7b80\u5355\uff1a\u4e0d\u518d\u53bb\u6539\u5f00\u5934\u7684 system \u5b57\u6bb5\uff0c\u800c\u662f\u5728 messages \u6570\u7ec4\u7684\u5f53\u524d\u4f4d\u7f6e\u8ffd\u52a0\u4e00\u6761 <code>{&quot;role&quot;: &quot;system&quot;}<\/code> \u6d88\u606f\u3002<\/p>\n<pre><code class=\"language-json\">  { &quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;\u73b0\u5728\u5ba1\u67e5\u8c03\u7528 process() \u7684\u4ee3\u7801\u3002&quot; },\n  { &quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;\u4ece\u73b0\u5728\u8d77,\u6bcf\u6761\u5efa\u8bae\u90fd\u5fc5\u987b\u5305\u542b\u663e\u5f0f\u7c7b\u578b\u6807\u6ce8\u3002&quot; }<\/code><\/pre>\n<p>\u5173\u952e\u70b9\uff1a\u4e3a\u4ec0\u4e48\u975e\u8981\u7528 system \u89d2\u8272\uff0c\u800c\u4e0d\u662f\u585e\u8fdb user \u6d88\u606f? \u533a\u522b\u5728\u4e8e\u4f18\u5148\u7ea7\u3002<\/p>\n<ul>\n<li>user \u6d88\u606f = \u6765\u81ea\u7ec8\u7aef\u7528\u6237<\/li>\n<li>system \u6d88\u606f = \u6765\u81ea(Agent \/ \u5e94\u7528\u8fd0\u8425\u65b9)<\/li>\n<\/ul>\n<p>\u5f53\u4e24\u8005\u51b2\u7a81\u65f6\uff0c\u7cfb\u7edf\u7ea7\u522b\u4f18\u5148\u3002\u6240\u4ee5\u5bf9\u4e8e\u90a3\u4e9b\u201c\u5373\u4f7f\u7528\u6237\u63d0\u51fa\u522b\u7684\u8981\u6c42\u4e5f\u5e94\u5f53\u575a\u6301\u201d\u7684\u8fd0\u8425\u7ea7\u7ea6\u675f\uff0c\u5e94\u8be5\u7528 <code>{&quot;role&quot;: &quot;system&quot;}<\/code> \u3002\u800c mid-conversation system message \u8ba9\u4f60\u65e2\u4fdd\u4f4f\u8fd9\u4efd\u4f18\u5148\u7ea7,\u53c8\u4e0d\u7528\u4ed8\u7f13\u5b58\u5931\u6548\u7684\u4ee3\u4ef7\u3002<\/p>\n<h1>3. \u5e38\u89c1\u573a\u666f<\/h1>\n<ul>\n<li>\u4e2d\u9014\u6539\u7b56\u7565\/\u4eba\u8bbe\uff1a\u957f\u4f1a\u8bdd\u8dd1\u4e86\u51e0\u5341\u8f6e\u540e\u8981\u52a0\u65b0\u7ea6\u675f\u3002<\/li>\n<li>\u5e94\u7528\u89c2\u6d4b\u5230\u7684\u72b6\u6001\u53d8\u5316\uff1a\u78c1\u76d8\u6587\u4ef6\u53d8\u4e86\u3001\u7528\u6237\u6253\u5f00\u4e86 yolo \u6a21\u5f0f\u3001\u4f7f\u7528\u9650\u989d\u8dcc\u7834\u9608\u503c\u2014\u2014\u8fd9\u4e9b\u662f\u300c\u8fd0\u8425\u7ea7\u4e8b\u5b9e\u300d\u3002<\/li>\n<li>\u6bcf\u8f6e\u90fd\u8981\u6743\u5a01\u6ce8\u5165\u7684\u4e0a\u4e0b\u6587\uff1a\u65f6\u6548\u6027\u63d0\u793a\u3001\u4f1a\u8bdd\u622a\u6b62\u65f6\u95f4\u3001\u53ef\u7528\u5de5\u5177\u53d8\u5316\u7b49,\u53d8\u52a8\u592a\u9891\u7e41\u4e0d\u9002\u5408\u653e\u56fa\u5b9a\u524d\u7f00\u3002<\/li>\n<li>\u4e0d\u6253\u65ad agentic \u5faa\u73af\u7684\u7528\u6237\u63d2\u8bdd\uff1aClaude \u6b63\u5728\u8dd1\u5de5\u5177\u65f6\u7528\u6237\u53c8\u53d1\u4e86\u4e00\u53e5\u8bdd\uff0c\u628a\u5b83\u4f5c\u4e3a\u7cfb\u7edf\u6d88\u606f\u653e\u5728\u4e0b\u4e00\u4e2a\u5de5\u5177\u7ed3\u679c\u4e4b\u540e\uff0cClaude \u5c31\u80fd\u628a\u65b0\u8f93\u5165\u878d\u5165\u5f53\u524d\u5de5\u4f5c\uff0c\u800c\u4e0d\u662f\u5f53\u6210\u4e00\u4e2a\u5168\u65b0\u8bf7\u6c42\u53bb\u5207\u6362\u3002\uff08\u8fd9\u4e2a\u5c55\u5f00\u8bb2\uff09<\/li>\n<\/ul>\n<h2>3.1 \u653e\u7f6e\u89c4\u5219 \u4e0e \u7528\u6237\u63d2\u8bdd<\/h2>\n<p>\u9996\u5148\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u4e0d\u80fd\u662f messages \u7684\u7b2c\u4e00\u6761(\u6574\u4e2a\u5bf9\u8bdd\u7684\u8d77\u59cb\u6307\u4ee4\u9700\u8981\u7528\u9876\u5c42 system prompt)\u3002<\/li>\n<li>\u5fc5\u987b\u7d27\u8ddf\u5728\u4e00\u4e2a user \u56de\u5408\u4e4b\u540e(\u5e26 tool_result \u7684 user \u6d88\u606f\u4e5f\u7b97),\u6216\u7d27\u8ddf\u670d\u52a1\u7aef\u5de5\u5177\u7ed3\u679c\u7ed3\u675f\u7684  assistant \u56de\u5408\u4e4b\u540e\u3002<\/li>\n<li>\u4e14\u5b83\u5fc5\u987b\u662f\u6570\u7ec4\u6700\u540e\u4e00\u6761,\u6216\u8005\u540e\u9762\u7d27\u8ddf\u4e00\u4e2a assistant \u56de\u5408\u3002<\/li>\n<li>\u7edd\u4e0d\u80fd\u63d2\u5728 tool_use \u548c\u5bf9\u5e94\u7684 tool_result \u4e4b\u95f4\u3002<\/li>\n<\/ul>\n<p>\u6700\u540e\u4e00\u6761\u89c4\u5219\u5f71\u54cd\u8f83\u5927\uff0c\u76f4\u63a5\u5bfc\u81f4\u4e86\u8fd9\u4e2a\u529f\u80fd\u53ef\u4ee5\u88ab\u7528\u4e8e\u7528\u6237\u63d2\u8bdd\u673a\u5236\u3002<\/p>\n<p>\u7531\u4e8e system message \u4e0d\u80fd\u5939\u5728 tool_use \u548c\u5b83\u7684 tool_result \u4e4b\u95f4\uff0c\u800c\u5de5\u5177\u521a\u8dd1\u5b8c\u3001\u7ed3\u679c\u521a\u56de\u6765\u7684\u90a3\u4e00\u523b\uff0c\u6b63\u662f Claude \u51c6\u5907\u51b3\u5b9a\u300c\u4e0b\u4e00\u6b65\u5e72\u561b\u300d\u7684\u65f6\u673a\u3002\u628a\u65b0\u8f93\u5165\u63d2\u5728\u8fd9\u91cc\uff0cClaude \u5728\u89c4\u5212\u4e0b\u4e00\u6b65\u65f6\u5c31\u80fd\u987a\u5e26\u628a\u65b0\u4fe1\u606f\u4e00\u8d77\u8003\u8651\u8fdb\u53bb\uff0c\u8854\u63a5\u6700\u81ea\u7136\uff0c\u4e5f\u4e0d\u8fdd\u53cd\u653e\u7f6e\u89c4\u5219\u3002<\/p>\n<h1>4. \u548c claude code system reminder \u7684\u5bf9\u6bd4<\/h1>\n<p>\u7b80\u5355\u8bb0\uff1a <code>&lt;system-reminder&gt;<\/code> \u662f\u300c\u4f2a\u88c5\u6210\u6587\u672c\u7684\u63d0\u9192\u300d(\u5e94\u7528\u5c42\u60ef\u4f8b)\uff0cmid-conversation system message  \u662f\u300c\u534f\u8bae\u627f\u8ba4\u7684\u6b63\u724c\u7cfb\u7edf\u6d88\u606f\u300d(API \u7279\u6027)\u3002\u524d\u8005\u662f\u540e\u8005\u51fa\u73b0\u4e4b\u524d\u7684\u66ff\u4ee3\u65b9\u6848\uff0c\u73b0\u5728\u6709\u4e86\u6b63\u89c4\u6e20\u9053\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>mid-conversation system message<\/th>\n<th><code>&lt;system-reminder&gt;<\/code><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u662f\u4ec0\u4e48<\/td>\n<td>API \u534f\u8bae\u91cc\u7684\u4e00\u79cd\u6d88\u606f\u89d2\u8272<\/td>\n<td>\u6ce8\u5165\u5230\u6d88\u606f\u6587\u672c\u5185\u5bb9\u91cc\u7684\u4e00\u6bb5\u6807\u8bb0<\/td>\n<\/tr>\n<tr>\n<td>\u4f4d\u7f6e<\/td>\n<td>messages \u6570\u7ec4\u91cc\u72ec\u7acb\u7684\u4e00\u6761 {&quot;role&quot;: &quot;system&quot;}<\/td>\n<td>\u585e\u5728\u67d0\u6761 user\/tool_result \u6d88\u606f\u7684 content \u5185\u90e8<\/td>\n<\/tr>\n<tr>\n<td>\u8c01\u5b9a\u4e49\u7684<\/td>\n<td>Anthropic \u7684 Messages API \u6b63\u5f0f\u7279\u6027<\/td>\n<td>\u5e94\u7528\u5c42\/harness(\u6bd4\u5982 Claude Code)\u81ea\u5df1\u7ea6\u5b9a\u7684\u4e00\u4e2a XML \u6807\u7b7e<\/td>\n<\/tr>\n<tr>\n<td>\u6a21\u578b\u600e\u4e48\u770b<\/td>\n<td>\u662f\u4e00\u6761\u771f\u6b63\u7684\u3001\u5e26\u7cfb\u7edf\u7ea7\u4f18\u5148\u6743\u7684\u72ec\u7acb\u6d88\u606f<\/td>\n<td>\u672c\u8d28\u8fd8\u662f\u666e\u901a\u6587\u672c\u3002\u53ea\u662f\u7528\u6807\u7b7e\u63d0\u793a\u300c\u8fd9\u6bb5\u662f\u80cc\u666f\u6ce8\u5165\u300d \u2502<\/td>\n<\/tr>\n<tr>\n<td>\u4f18\u5148\u7ea7<\/td>\n<td>\u7cfb\u7edf\u7ea7\uff0c\u51b2\u7a81\u65f6\u538b\u8fc7 user<\/td>\n<td>\u6ca1\u6709\u534f\u8bae\u5c42\u7684\u7279\u6b8a\u6743\u91cd,\u9760\u8bad\u7ec3\/\u7ea6\u5b9a\u6765\u300c\u5f53\u56de\u4e8b\u300d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u6765\u6e90\uff1a https:\/\/platform.claude.com\/docs\/en\/build-with-clau [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,45],"tags":[44,46],"class_list":["post-627","post","type-post","status-publish","format-standard","hentry","category-ai","category-claude","tag-ai","tag-claude"],"_links":{"self":[{"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/posts\/627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/comments?post=627"}],"version-history":[{"count":1,"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/posts\/627\/revisions"}],"predecessor-version":[{"id":628,"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/posts\/627\/revisions\/628"}],"wp:attachment":[{"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/media?parent=627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/categories?post=627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cococat.top\/index.php\/wp-json\/wp\/v2\/tags?post=627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}