Bug: Opus 4.8 outputs tool calls as code fences instead of executing them
Bug: Opus 4.8 outputs tool calls as ```bash code fences instead of executing them
Claude Code version: 2.1.162 (CLI and Cursor extension, both confirmed)
Model: claude-opus-4-8
Environment: Cursor IDE extension (anthropic.claude-code), macOS darwin arm64
---
Summary
When using Opus 4.8, Claude frequently outputs shell commands and tool calls (Bash, Edit, Agent, etc.) as `bash ` markdown code fences in plain text, instead of executing them as proper tool calls. The harness does not execute fenced content, so work stops until the user manually prompts the model to retry without the fence.
This does not happen consistently — it occurs unpredictably across different tool types (Bash, Edit, TodoWrite, Agent), and switching to Sonnet 4.6 eliminates the issue.
---
Steps to Reproduce
- Start a Claude Code session with model
claude-opus-4-8in Cursor extension - Ask Claude to run any shell command (e.g., "check docker ps")
- Observe: Claude outputs the command wrapped in
`bash ...`as text, rather than invoking the Bash tool
---
Expected Behavior
Claude calls the Bash (or Edit, Agent, etc.) tool directly. The harness executes it.
Actual Behavior
Claude outputs something like:
I'll check the container status.
```bash
docker ps --format '{{.Names}}: {{.Status}}' | grep mysql
` ``` `
The command is never executed. Work halts.
---
Additional Context
- Affects multiple tool types: Bash, Edit, TodoWrite, Agent — not just Bash
- Reproduced after updating both CLI and extension to 2.1.162 (version unification did not fix it)
- Workaround: switching to
claude-sonnet-4-6eliminates the issue entirely (per issue #64129 which reports similar Opus 4.8 tool-call instability) - A
Stophook detecting the fenced output and prompting retry partially mitigates the symptom but does not prevent it - The
/feedbackcommand is not available in the Cursor extension environment (/feedback isn't available in this environment)
Related: #64129 (Opus 4.8 responses not displayed after tool use)
---
Workaround (for others hitting this)
Use claude-sonnet-4-6 for tool-heavy personas (orchestrator, director, pm, engineers). Reserve Opus for analysis/review tasks where tool calls are infrequent.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗