[BUG] Agent model shorthand names (sonnet/opus/haiku) cause 404 errors - not translated like Task tool

Resolved 💬 3 comments Opened Jan 11, 2026 by hflier Closed Feb 27, 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?

When defining agents in project configuration files (e.g., marketplace.json or agent definition files) with shorthand model names like "model": "sonnet", the API returns a 404 error:

404 {"type":"error","error":{"type":"not_found_error","message":"model: sonnet"}}

The shorthand name is passed directly to the Anthropic API without translation to the full model ID.

What Should Happen?

Shorthand model names (sonnet, opus, haiku) should be translated to full model IDs before being sent to the API, consistent with how the Task tool handles model selection.

The Task tool explicitly accepts shorthand names in its schema:

"model": {"enum": ["sonnet", "opus", "haiku"], "type": "string"}

And correctly translates them internally. Agent definitions should use the same translation layer.

Error Messages/Logs

2026-01-11T14:37:59.325Z [ERROR] Error streaming, falling back to non-streaming mode: 404 {"type":"error","error":{"type":"not_found_error","message":"model: sonnet"},"request_id":"req_011CX1m6WpkUh8UVsjLaZYBD"}

This error occurred 1,533 times in 48 hours of logs when agents were defined with "model": "sonnet".

Steps to Reproduce

  1. Create a project agent definition with "model": "sonnet" (or any shorthand)
  2. Invoke the agent (via Task tool or command that spawns it)
  3. Observe 404 error: model: sonnet not found

Example agent definition that triggers this:

{
  "name": "code-reviewer",
  "file": "agents/code-reviewer.md",
  "model": "sonnet",
  "purpose": "General Swift code review"
}

Claude Model

Opus 4.5

Is this a regression?

I don't know

Claude Code Version

2.1.4

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

zsh

Additional Information

Workaround: Remove the "model" field from agent definitions so they inherit from parent context, which does handle translation correctly.

Related: This is similar to closed issue #7304 where "model": "inherit" was passed directly to the API.

Inconsistency: The Task tool correctly accepts and translates shorthand names, but agent spawning code does not apply the same translation.

View original on GitHub ↗

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