[Bug] Tool-call markup leaks into assistant text after large context accumulation

Open 💬 2 comments Opened Jun 27, 2026 by OrekhovAlexey

Bug Description
Title: Tool-call markup (<invoke>) leaks into assistant text instead of executing, after several hours / large context

Environment

  • Claude Code: 2.1.195 (native installer, ~/.local/bin/claude)
  • Model: Opus 4.8 (1M context) — claude-opus-4-8[1m]
  • Node: v24.13.1
  • OS: Ubuntu 24.04.4 LTS, kernel 6.8.0-117 x86_64
  • Experimental: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 (enabled)
  • Session ID: e026e4e8-dad3-4b21-b77f-253a61e62383

What happens
After ~several hours into a session (multiple auto-compactions), the model
starts printing the raw tool-call markup as literal assistant text instead
of invoking the tool. The function-call block delimiters and the antml:
namespace prefix appear verbatim on screen; the tool never runs.

Example of leaked output (rendered as text, not executed):court
<invoke name="Bash">
<parameter name="command">cd /home/gaffer/Plansmen
grep -n "reassign|release_to_open|target" frontend/src/widgets/dashboard/lib/transferApprove.ts
git status --short | wc -l
rm -f /tmp/codex-review-result.md
timeout 540 /home/gaffer/.npm-global/bin/codex exec review --uncommitted -o /tmp/codex-review-result.md --ephemeral --ignore-user-config -m gpt-5.5 --dangerously-bypass-approvals-and-sandbox 2>&1 | tail -3
echo "=== RESULT ==="
cat /tmp/codex-review-result.md 2>&1</parameter>
<parameter name="description">Verify transfer fix and run Codex review of 3177</parameter>
<parameter name="run_in_background">true</parameter>
</invoke>Correlation

  • Only after the session has been running for hours / context is large.
  • A fresh session (/clear) resolves it until context grows again.
  • agent-teams mode is on, with frequent large teammate-message injections.

Expected: function-call block is parsed and the tool executes.
Actual: delimiters/namespace leak into visible text; no tool execution.

Frequency: reproducible on long sessions; not on fresh ones.

Environment Info

  • Platform: linux
  • Terminal: kitty
  • Version: 2.1.195
  • Feedback ID: 6e6b7313-9bba-4558-91e7-2fe953090c9d

Errors

[]

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗