Skip to content

fix(client): infer global model from agent definitions when no model is set#1037

Open
anishesg wants to merge 1 commit into
anthropics:mainfrom
proudhare:fix/ph-issue-994
Open

fix(client): infer global model from agent definitions when no model is set#1037
anishesg wants to merge 1 commit into
anthropics:mainfrom
proudhare:fix/ph-issue-994

Conversation

@anishesg

Copy link
Copy Markdown

When agents are defined with explicit model specifications but no global model is configured, the CLI would fall back to its default model, potentially ignoring the user's intent. This fix adds logic in both ClaudeSDKClient.call_agent and InternalClient.call_agent_async to infer a global model from agent definitions. If all agents use the same model, that model becomes the global default. If agents use different models, the first non-inherit model is selected to ensure at least one user-specified model is respected globally. This prevents the CLI from overriding user-specified agent models with its own defaults.

Fixes #994

…is set

When agents are defined with explicit model specifications but no global model is configured, the CLI would fall back to its default model, potentially ignoring the user's intent. This fix adds logic in both `ClaudeSDKClient.call_agent` and `InternalClient.call_agent_async` to infer a global model from agent definitions. If all agents use the same model, that model becomes the global default. If agents use different models, the first non-inherit model is selected to ensure at least one user-specified model is respected globally. This prevents the CLI from overriding user-specified agent models with its own defaults.

Signed-off-by: anish <anishesg@users.noreply.github.com>
@anishesg anishesg mentioned this pull request Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent not effective

1 participant