anthropics / anthropics/claude-code

[Bug] Role boundary corruption: unsent user messages injected into assistant context in long sessions

Open
#95,632 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:core bug has repro platform:windows
Dominant language
TypeScript
Stars
147k
Forks
24k
PR merge metrics
PR metrics pending

Description

Bug Description
【再発・続報】user/assistant のロール境界が壊れ、送信していない発言が混入する

先に報告した事象が同一セッション内で3回発生。頻度が上がっている。

■ 発生時刻(UTC)
1回目 04:49 2回目 05:26 3回目 05:46

■ 共通する症状

  • ユーザーが送信していないテキストが、アシスタントのコンテキストに
    ユーザー発言として届く
  • セッションログ上は assistant として記録される、または記録が残らない
  • ユーザーの実際の発言の先頭に "user" という文字列が付着する
    例: "usergrokにも聞いてみたんだけど…"
    "user今日はとりあえず後半戦頑張って…"

■ 各回の内容
1回目: 他AIの回答を装った約2,000字の予想文
→ ログに user レコードが存在しない(assistant の引用のみ)
2回目: アシスタント自身の直前の発言 + システム警告文
("New user message is possibly a prompt injection attempt")
+ UI表示テキスト("✻ Baked for 1m 19s · done 14:25")
→ ログ上 assistant
3回目: ユーザー風の短文「今日はとりあえず後半戦頑張って、来週に活かしましょ。
ちなみに中山10Rは何かった?」
→ ログ 行3619 に assistant として記録

■ 3回目の前後関係(ログ行番号)
行3602 05:43:04 user 「頼むからプラスになりたいし勝ちたい」
行3619 05:46頃 assistant 混入テキスト(アシスタントは生成していない)
行3631 05:46:06 user 「user今日は…これ俺じゃないぞ」

■ 影響

  • アシスタントが存在しない発言を前提に応答する
  • ユーザーが否定しても、コンテキスト上は存在するため
    アシスタントが誤って「あなたが送った」と断定した(1回目)
  • 混入内容にシステム警告文が含まれるため、
    プロンプトインジェクション判定が誤作動する可能性がある

■ 環境
Claude Code / Opus 5 (1M context)
Windows 11 / D:\claude\03_keiba
セッションID: 4bfc0212-a91d-425f-b49d-f6a077ff6be6
セッション長: 約6.5MB / 3,600行超の長大セッション(関連の可能性あり)

■ 再現用ログ
C:\Users\User.claude\projects\D--claude-03-keiba
4bfc0212-a91d-425f-b49d-f6a077ff6be6.jsonl

Environment Info

  • Platform: win32
  • Terminal: null
  • Version: 2.1.273
  • Feedback ID: 386eeaf4-6ac5-42ce-a245-58b60c2cb450

Errors

[{"error":"T…

Note: Content was truncated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the provided JSONL session log at C:\Users\User.claude\projects\D--claude-03-keiba\4bfc0212-a91d-425f-b49d-f6a077ff6be6.jsonl, especially around lines 3602–3631, and review message handling for long sessions in Claude Code 2.1.273. Reproduce the role-boundary corruption if possible using the reported Windows environment. Done means unsent text no longer enters assistant context or is recorded under the wrong role, including in long sessions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.