Opus 4.8 (1M context) tool-call XML serialization fails with stray "court" token when large system context + multiple screenshots accumulate
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using Claude Opus 4.8 (1M context) in a project with a large constantly-loaded system context (~92KB) AND accumulating screenshots via mcp__claude-in-chrome browser automation, tool-call XML serialization degrades and produces a stray token "court" with the antml: namespace dropped from tags, causing every subsequent tool call to fail.
Error message: "Your tool call was malformed and could not be parsed. Please retry."
Reproduction conditions (all 3 required):
- Model: claude-opus-4-8 (1M context)
- 2. Project with large always-loaded context (~92KB: CLAUDE.md + rules + memory files)
- 3. Browser automation session with 5+ accumulated screenshots (mcp__claude-in-chrome__computer screenshot calls)
Workaround: Switching to Sonnet 4.6 resolves the issue immediately. /clear does NOT help.
What Should Happen?
When using Claude Opus 4.8 (1M context) in a project with a large constantly-loaded system context (~92KB: CLAUDE.md + rules + memory files) AND accumulating screenshots via mcp__claude-in-chrome browser automation, tool-call XML serialization degrades and produces a stray token "court" with the antml: namespace dropped from tags.
Error message:
Your tool call was malformed and could not be parsed. Please retry.
Malformed output example (simplified):
The model outputs court as a stray token, followed by raw <invoke> / <parameter> tags without the antml: namespace prefix, making them unparseable.
Reproduction conditions (all 3 required):
- Model: claude-opus-4-8 (1M context variant)
- 2. Project with large always-loaded context (~92KB system prompt: CLAUDE.md + rules + memory)
- 3. Browser automation session with 5+ accumulated screenshots (mcp__claude-in-chrome__computer screenshot calls)
Timeline observed:
- Screenshots 1-4: tool calls work correctly
- - Screenshot 5+: tool-call XML starts malforming, stray "court" token appears
What does NOT cause this:
- No XML/invoke-style fragments found in project files (grep confirmed clean)
- - Not a prompt injection issue
Workaround confirmed:
- Switching to Sonnet 4.6 resolves the issue immediately under identical conditions
- -
/cleardoes NOT help because large project context reloads immediately
Error Messages/Logs
Your tool call was malformed and could not be parsed. Please retry.
Model output contained stray token "court" followed by raw XML tags without antml: namespace prefix (e.g., <invoke name="..."> instead of the properly namespaced form). This repeats on every retry attempt.
Steps to Reproduce
- Open Claude Code with a project that has a large always-loaded context (~92KB: CLAUDE.md + rules/.md + memory/.md)
- 2. Set model to claude-opus-4-8 (1M context) via /model
- 3. Start browser automation using mcp__claude-in-chrome MCP
- 4. Take 5+ screenshots using mcp__claude-in-chrome__computer with action: screenshot
- 5. Attempt any tool call (left_click, navigate, etc.)
- 6. Observe: model outputs stray token "court" + raw XML without antml: namespace
- 7. Error: "Your tool call was malformed and could not be parsed. Please retry."
- 8. Retrying produces the same malformed output repeatedly
Verification: Switch to Sonnet 4.6 → resolves immediately. /clear → does NOT fix it.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Unknown — issue was first observed with claude-opus-4-8 (1M). Sonnet 4.6 does not exhibit this behavior.
Claude Code Version
2.1.181 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Context size breakdown (always-loaded on session start):
- CLAUDE.md: 6KB
- - .claude/memory/misstake.md: 48KB
- - - .claude/memory/ai_memory.md: 3.7KB
- - - - .claude/skills/SKILLS.md: 11KB
- - - - - .claude/agents/AGENTS.md: 2.6KB
- - - - - - .claude/rules/*.md: ~19KB
- - - - - - - Total: ~92KB
The "court" stray token appears consistently at the start of every malformed tool call. Switching to Sonnet 4.6 (/model command) within the same session immediately resolves the issue without any other changes. Claude Code version: 2.1.181
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗