1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

対話の途中でシステムプロンプトを切り替える(mid-conversation system messages)仕様解説

1
Posted at

Claude API では、会話が始まったあとでも messages 配列の途中に system メッセージを差し込み、指示を更新できる機能が段階的に追加されてきました。本稿は公式リリースノート(2026-10-06 時点)に記載された範囲で、初期実装・ターンスコープ指示・インラインツール定義・thinking ブロック再生時の制約を整理します。対応モデルは各機能で異なるため、導入前に必ず公式リリースノートで確認してください。

初期実装:ユーザーターン後の system メッセージ(2026-05-28)

2026-05-28 リリースの初期実装では、messages 配列内でユーザーターンの後に role: "system" メッセージを送信できます。配置ルールに従う限り、長時間セッション中に指示が変わってもプロンプトキャッシュのヒットを維持できます。この機能にベータヘッダーは不要です。

you can send role: "system" messages after a user turn (subject to placement rules) in the messages array, preserving prompt cache hits when instructions change during a long-running session. No beta header is required.

要するに、会話の途中で指示を足しても、冒頭からのキャッシュを捨てずに済むという仕様です。

ターンスコープのシステムメッセージ:clear_at(2026-09-01)

2026-09-01 リリースでは、mid-conversation の role: "system" メッセージに clear_at: "next_user_message" を設定できます。この指示は現在のターンのみレンダリングされ、その後はトークンコストゼロで履歴に残ります。利用にはベータヘッダー mid-conversation-system-clear-at-2026-08-21 が必要です。

Set clear_at: "next_user_message" on a mid-conversation role: "system" message and it renders for the current turn only, then stays in the history at no token cost

この per-turn リマインダーは蓄積せず、プロンプトキャッシュや後続の thinking ブロックを無効化しません。

Per-turn reminders don't accumulate and don't invalidate the prompt cache or later thinking blocks.

インラインツール定義(2026-09-22)

2026-09-22 より、mid-conversation system メッセージ内でツールを定義できるようになりました。Claude API のベータ機能で、ベータヘッダー inline-tools-2026-09-15 が必要です。対応モデルは公式ドキュメントを参照してください。tool_addition ブロックにツールの完全な定義(tool: {"type": "tool_definition", "definition": {...}})を載せることで、トップレベルの tools を編集せず、プロンプトキャッシュも無効化せずに、ツールの追加・スキーマ変更・サーバーツールの新バージョン移行ができます。

Tools can now be defined inside a mid-conversation system message

thinking ブロック再生時の 400 エラー(Claude Fable 5.1)

Claude Fable 5.1 では、2026-08-31 以降に作成された新規アカウントにおいて、システムプロンプト・ツール・以前のメッセージを変更した後に thinking ブロックを再生すると 400 エラーが返されます。

for new accounts created on or after August 31, 2026, replaying one after the system prompt, tools , or an earlier message changed returns a 400 error

References

[1] https://platform.claude.com/docs/en/release-notes/overview

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?