Tool call intermittently emitted as literal "count" (antml: prefix dropped, "could not be parsed") in long Opus 4.8 1M-context sessions
Summary
In long Claude Code sessions on Opus 4.8 (1M context), tool calls intermittently fail with:
Your tool call was malformed and could not be parsed. Please retry.
The malformed output renders the function-call opening tag as the literal word count, and the antml: namespace prefix on invoke / parameter is dropped. The command therefore never executes and the model appears to "stall" mid-task.
Environment
- Model: Opus 4.8, 1M context (
claude-opus-4-8[1m]) - Client: Claude Code CLI
- Platform: macOS (darwin)
- Session: very long-running (many turns, large accumulated context)
Observed symptom
Instead of a well-formed tool call, the assistant emits plain text like:
count
cd /path && some-command
<description text>
i.e. the wrapper start tag is the literal token count, and invoke / parameter appear without the antml: prefix. The harness reports it as malformed.
Reproduction pattern (empirical, from one long session)
- High frequency when: a single tool call immediately follows a long prose / markdown reply in the same message.
- Low / no frequency when: multiple tool calls are batched into one message, or there is little/no prose before the call.
- Re-sending the same call (with the correct
antml:prefix) usually succeeds on the next attempt. - Frequency increases as the session grows longer — rare early, very frequent late in a long 1M-context session.
Impact
Repeatedly interrupts the workflow in long sessions: commands silently fail to run, the user sees raw count + command text in the reply, and progress halts until the call is re-issued. Starting a fresh session (clean context) effectively avoids it.
Notes
This appears to be a model-side generation / serialization issue, not a CLI execution bug — tool execution itself works fine once the call is correctly formed. Possibly related to context length and 1M-context Opus 4.8 routing. Filing in case it helps correlate with other reports.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗