[BUG] opus 4.8 Tool invocation XML tags intermittently corrupted — antml:invoke rendered as raw text

Resolved 💬 2 comments Opened Jun 2, 2026 by sehyunko-publ Closed Jun 5, 2026

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?

Description

Tool invocation opening tags are intermittently corrupted during generation, causing the raw XML markup to be printed as plain text
instead of being executed as a tool call. The tag name antml:invoke gets partially garbled (e.g., antml:invoke → antml:court,
antml:call, or similar corruptions), which breaks the tool dispatch and surfaces internal markup to the user.

What Should Happen?

Reproduction

  • Frequency: Intermittent — not every tool call, but recurs within the same session across multiple attempts.
  • Tool types affected: All tool types — Bash, Grep, Edit, Read, etc. No specific tool is immune.
  • Context: Appears more frequently during or immediately after background Bash calls (run_in_background: true), but also occurs with

foreground tool invocations.

  • Model: Claude Opus 4.6 (1M context) via Claude Code CLI.

Expected Behavior

All tool invocation tags should be generated with correct syntax and dispatched to the tool execution layer without corruption.

Actual Behavior

The opening <invoke> tag is occasionally generated with a corrupted tag name (e.g., <court>, <call>), causing the entire tool call
block to be treated as plain text output. The closing tag remains correct, creating a mismatch. The user sees raw XML markup in
their terminal.

Environment

  • Claude Code CLI (latest as of 2026-06-02)
  • macOS (Darwin 23.6.0)
  • Model: claude-opus-4-6[1m]
  • Multiple MCP servers connected (3+)
  • Long-running sessions with mixed foreground/background tool calls

Error Messages/Logs

--

Steps to Reproduce

Steps to Reproduce

  1. Start a Claude Code session with multiple MCP servers connected (higher tool count may increase likelihood).
  2. Perform a mix of foreground and background tool calls over an extended session.
  3. Observe that some tool calls fail to execute — the opening XML tag is corrupted and rendered as raw text in the user transcript.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

4.8

Claude Code Version

2.1.79

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

This appears to be a token generation issue rather than a client-side parsing issue, since the corruption occurs in the model's
output stream before the client has a chance to parse it. The corruption pattern suggests adjacent tokens in the vocabulary are
being selected instead of the correct token for the tag name.

View original on GitHub ↗

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