claude-code - 💡(How to fix) Fix [BUG] v2.1.154 regression: custom agents via `/agents` fail with "messages[1].role: unknown variant `system`"

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

API Error: 400 Failed to deserialize the JSON body into the target type: messages[1].role: unknown variant system, expected user or assistant at line 1 column 16679

Fix Action

Fix / Workaround

  • Works on: v2.1.153
  • Broken on: v2.1.154
  • Fresh session: Yes — I deleted all conversation history (.jsonl files) and the error still occurs on a brand new conversation with zero history
  • Column position is consistent: Always around column 16679, which corresponds to the size of my CLAUDE.md (~15KB) — suggesting the agent system prompt is being placed as a role: "system" message inside the messages array instead of the top-level system parameter
  • Workaround: npm install -g @anthropic-ai/[email protected]

Code Example

API Error: 400 Failed to deserialize the JSON body into the target type: messages[1].role: unknown variant `system`, expected `user` or `assistant` at line 1 column 16679
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

After auto-updating from v2.1.153 to v2.1.154, invoking a custom agent via /agents immediately fails with an API 400 error. The same agent works perfectly on v2.1.153. Rolling back to 2.1.153 resolves the issue.

What Should Happen?

should no error

Error Messages/Logs

API Error: 400 Failed to deserialize the JSON body into the target type: messages[1].role: unknown variant `system`, expected `user` or `assistant` at line 1 column 16679

Steps to Reproduce

  1. Have a custom agent defined in .claude/agents/ (mine is ~24KB with memory instructions)
  2. Update to v2.1.154 (or let auto-update apply it)
  3. Start a new session: claude
  4. Run /agents and select the custom agent
  5. Send any message

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.154

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

  • Works on: v2.1.153

  • Broken on: v2.1.154

  • Fresh session: Yes — I deleted all conversation history (.jsonl files) and the error still occurs on a brand new conversation with zero history

  • Column position is consistent: Always around column 16679, which corresponds to the size of my CLAUDE.md (~15KB) — suggesting the agent system prompt is being placed as a role: "system" message inside the messages array instead of the top-level system parameter

  • Workaround: npm install -g @anthropic-ai/[email protected]

  • #60947 — same error message but triggered by long/compacted sessions. This issue is a v2.1.154 regression that hits on fresh sessions with custom agents.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING