[Bug] Tool call occasionally emitted as literal text (missing namespace prefix, preceded by stray "card" token) instead of a real tool_use invocation

Status Open
Maintainer reply None cached
Activity 0 comments · opened Jul 20, 2026

Description

Intermittently, after a long internal reasoning block, the model fails to emit a tool call as a proper structured tool_use block. Instead, the tool-call syntax is emitted as plain assistant text — with the tool namespace prefix dropped, and preceded by a stray, unrelated token: the literal word "card".

Because the harness never recognizes this as a tool invocation, no tool actually executes. The turn simply ends with a text message that contains raw, unexecuted invoke syntax.

Exact reproduction pattern (verbatim from transcript logs, unmodified):

...(preceding reasoning/analysis text)...

card
<invoke name="Bash">
<parameter name="command">...</parameter>
<parameter name="description">...</parameter>
</invoke>

Three consistent characteristics:

  1. Missing namespace prefix — should be antml:invoke / antml:parameter, but appears as bare <invoke> / <parameter>.
  2. A stray, context-irrelevant token — literally "card" — immediately precedes <invoke.
  3. Almost always occurs immediately after a comparatively long chain-of-thought/reasoning block, right at the transition into structured tool-call output.

Frequency

Observed 10 times within a single ~7-hour session in one sub-agent. The issue also recurred multiple times in a freshly restarted session with a short history (under 10 hours old), ruling out "long context accumulation" as the root cause — it appears tied to the reasoning→tool-call transition itself, not session length.

Impact

Each occurrence silently drops the intended tool call. The agent must notice the missing tool result on its own and re-issue the call, causing response delay and making the agent appear to external observers as if it announced an action without taking it.

What does NOT fix it

Restarting the session/agent does not prevent recurrence — confirmed by reproduction in a brand-new session shortly after restart.

Observed (partial) mitigation

Writing complex/multi-line logic to a script file first (via the Write tool, which has not exhibited this failure mode), then invoking it with a short one-line bash <script_path> call, appears to reduce recurrence. This is a workaround, not a fix.

Question

Is there a hook mechanism that can inspect the full text of a just-completed turn for this pattern and force a retry? PreToolUse/PostToolUse hooks appear inapplicable since no tool invocation event occurs in

View original on GitHub ↗