claude-code - 💡(How to fix) Fix SendMessage ignores model specified at Agent creation, falls back to default [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#45228Fetched 2026-04-09 08:10:17
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

When creating a subagent via Agent(), you can specify a model (model: "haiku", model: "sonnet", etc.). The agent launches on the chosen model correctly. However, when resuming the same agent via SendMessage(), the model is not inherited — instead, the system's default model is used (e.g., Sonnet if configured as default), regardless of both the original Agent() model choice and the orchestrator's model.

Error Message

  • Agent(model: "haiku") → runs on haiku ✅
  • SendMessage() to the same agent → switches to the system default model (not the orchestrator's model, not the agent's original model)
  • The agent's accumulated context is now fed into a different model

Root Cause

  • Cost: agent was created on haiku (cheap) for simple tasks, but on resume silently switches to sonnet/opus — cost increases 5-60x with no indication
  • Inconsistency: a subagent = context + role + model. On resume, context is preserved but model is lost — this breaks the "long-lived agent" abstraction
  • No workaround: SendMessage has no model parameter, so there's no way to manually fix this

Fix Action

Fix / Workaround

  • Cost: agent was created on haiku (cheap) for simple tasks, but on resume silently switches to sonnet/opus — cost increases 5-60x with no indication
  • Inconsistency: a subagent = context + role + model. On resume, context is preserved but model is lost — this breaks the "long-lived agent" abstraction
  • No workaround: SendMessage has no model parameter, so there's no way to manually fix this

Code Example

Agent(name: "worker", model: "haiku", prompt: "Do something")
RAW_BUFFERClick to expand / collapse

Description

When creating a subagent via Agent(), you can specify a model (model: "haiku", model: "sonnet", etc.). The agent launches on the chosen model correctly. However, when resuming the same agent via SendMessage(), the model is not inherited — instead, the system's default model is used (e.g., Sonnet if configured as default), regardless of both the original Agent() model choice and the orchestrator's model.

Reproduction

  1. Configure Claude Code with Opus as orchestrator and Sonnet as the default model
  2. Spawn a subagent with an explicit model:
    Agent(name: "worker", model: "haiku", prompt: "Do something")
  3. Agent runs on haiku — OK
  4. Resume via SendMessage(to: "<agent-id>", message: "Next task")
  5. Agent now runs on sonnet (the system default) instead of haiku

Observed behavior

  • Agent(model: "haiku") → runs on haiku ✅
  • SendMessage() to the same agent → switches to the system default model (not the orchestrator's model, not the agent's original model)
  • The agent's accumulated context is now fed into a different model

Expected behavior

The model specified at Agent() creation should persist for the entire lifecycle of that agent. SendMessage should automatically use the same model as the original Agent() call.

At minimum, one of:

  1. Preferred: SendMessage inherits the model from the original Agent() call
  2. Alternative: add a model parameter to SendMessage so the model can be explicitly set on resume

Why this matters

  • Cost: agent was created on haiku (cheap) for simple tasks, but on resume silently switches to sonnet/opus — cost increases 5-60x with no indication
  • Inconsistency: a subagent = context + role + model. On resume, context is preserved but model is lost — this breaks the "long-lived agent" abstraction
  • No workaround: SendMessage has no model parameter, so there's no way to manually fix this

Environment

  • Claude Code CLI (latest)
  • Orchestrator: claude-opus-4-6
  • Default model in config: claude-sonnet-4-6
  • Subagent: created with model: "haiku"
  • OS: macOS 13.5

extent analysis

TL;DR

To fix the issue, add a model parameter to the SendMessage function to explicitly set the model on resume, ensuring it matches the original model specified at Agent() creation.

Guidance

  • Verify the current behavior by checking the model used after resuming an agent via SendMessage to confirm it switches to the system default model.
  • Consider modifying the SendMessage function to include a model parameter, allowing for explicit model specification on resume.
  • If modifying SendMessage is not feasible, explore alternative solutions, such as storing the original model choice with the agent's context and manually setting it before resuming the agent.
  • Test the proposed fix with different models and scenarios to ensure the model persistence works as expected.

Example

# Proposed modification to SendMessage
def SendMessage(to: str, message: str, model: str = None):
    # If model is not provided, use the original model specified at Agent creation
    if model is None:
        # Retrieve the original model from the agent's context
        model = get_original_model(to)
    # Resume the agent with the specified model
    resume_agent(to, message, model)

Notes

The provided solution assumes that the original model choice can be stored and retrieved from the agent's context. If this is not possible, alternative solutions may need to be explored.

Recommendation

Apply workaround: Add a model parameter to the SendMessage function to ensure the model specified at Agent() creation persists throughout the agent's lifecycle. This allows for explicit control over the model used on resume, addressing the cost, inconsistency, and lack of workaround concerns.

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…

FAQ

Expected behavior

The model specified at Agent() creation should persist for the entire lifecycle of that agent. SendMessage should automatically use the same model as the original Agent() call.

At minimum, one of:

  1. Preferred: SendMessage inherits the model from the original Agent() call
  2. Alternative: add a model parameter to SendMessage so the model can be explicitly set on resume

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix SendMessage ignores model specified at Agent creation, falls back to default [1 comments, 2 participants]