[Bug] Tool calls intermittently emitted as plain text in large context sessions
Bug Description
[Bug] Tool calls intermittently emitted as plain text → "Your tool call was
malformed and could not be parsed. Please retry."
Environment: Claude Code, model Opus 4.8 (1M context).
Symptom:
In a long-running session, the model intermittently emits tool invocations as
visible plain text (the literal function-call wrapper leaks into the assistant
message) instead of a properly structured tool call. The harness rejects it with
"Your tool call was malformed and could not be parsed. Please retry." No tool
actually executes.
Reproduction pattern:
- Happens more frequently as conversation context grows large.
- Affects multiple tool types (file edits and shell commands alike).
- Re-issuing the exact same call in correct form succeeds immediately, so the
failure is in output formatting, not in the tool arguments themselves.
- Occurred repeatedly across many turns in a single long session.
Impact:
- Each occurrence wastes a turn and requires a manual retry.
- Because hooks fire only after a tool call is successfully parsed (Pre/PostToolUse),
there is no way to intercept or auto-retry this at the hook layer — it must be
handled by the model/parser itself.
Request:
- Investigate why structured tool calls degrade to plain text under large context.
- Consider an automatic retry/repair path at the parser layer for malformed tool
calls, since hooks cannot reach this stage.
Environment Info
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 2.1.179
- Feedback ID: 275a51fa-d9bd-4ded-b17b-076c8921998f
Errors
[]This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗