Skip to content

Update default anthropic model to sonnet 4.5#1580

Merged
dgageot merged 1 commit intodocker:mainfrom
krissetto:default-cagent-run-model-updates
Feb 3, 2026
Merged

Update default anthropic model to sonnet 4.5#1580
dgageot merged 1 commit intodocker:mainfrom
krissetto:default-cagent-run-model-updates

Conversation

@krissetto
Copy link
Contributor

And allow users to define their own default model in their global config

Both full model def and shorthand formats are supported

Examples of global config.yaml

version: v1
default_model:
    provider: anthropic
    model: claude-haiku-4-5
    max_tokens: 64000
    thinking_budget: 10000
    provider_opts:
        interleaved_thinking: true
version: v1
default_model: anthropic/claude-opus-4-5

@krissetto krissetto requested a review from a team as a code owner February 3, 2026 15:17
@krissetto krissetto self-assigned this Feb 3, 2026
…ne their own default model in their global config

Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
@krissetto krissetto force-pushed the default-cagent-run-model-updates branch from 667c164 to f335c41 Compare February 3, 2026 15:33
@derekmisler
Copy link
Contributor

/review

@dgageot dgageot merged commit dc6a502 into docker:main Feb 3, 2026
5 checks passed
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Found 2 issues in the new code that should be addressed:

  1. Silent failure when parsing invalid CAGENT_DEFAULT_MODEL - Users setting an invalid environment variable format won't receive any feedback
  2. Potential invalid YAML output - Empty model configs could produce invalid shorthand format

The core functionality looks good, but these edge cases should be handled more gracefully.


// Precedence for default model: environment variable > user config
if model := os.Getenv(envDefaultModel); model != "" {
runConfig.DefaultModel = parseModelShorthand(model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent failure when parsing invalid environment variable

When CAGENT_DEFAULT_MODEL is set to an invalid format (e.g., "anthropic" without /model, or "/model" without provider), parseModelShorthand returns nil silently with no warning or error. This means:

  1. The user's explicit configuration is ignored without any feedback
  2. The system falls back to auto-detection or user config without the user knowing
  3. Users may waste time debugging why their environment variable isn't working

Recommendation: Add a warning log when the environment variable is set but parsing fails:

if model := os.Getenv(envDefaultModel); model != "" {
    runConfig.DefaultModel = parseModelShorthand(model)
    if runConfig.DefaultModel == nil {
        slog.Warn("Invalid CAGENT_DEFAULT_MODEL format, expected 'provider/model'", "value", model)
    }
} else if userCfg.DefaultModel != nil {
    runConfig.DefaultModel = &userCfg.DefaultModel.ModelConfig
}

This gives users immediate feedback when they've misconfigured the environment variable.

if f.isShorthandOnly() {
return yaml.Marshal(f.Provider + "/" + f.Model)
}
return yaml.Marshal(f.ModelConfig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MarshalYAML can output invalid shorthand format

isShorthandOnly() only checks if advanced fields are unset, but doesn't verify that Provider and Model are non-empty. If a FlexibleModelConfig is created with zero values (empty Provider and Model), isShorthandOnly() would return true, causing MarshalYAML to output "/" (empty + "/" + empty), which is invalid.

Recommendation: Add validation in isShorthandOnly() to ensure both fields are non-empty:

func (f *FlexibleModelConfig) isShorthandOnly() bool {
    return f.Provider != "" &&
        f.Model != "" &&
        f.Temperature == nil &&
        f.MaxTokens == nil &&
        // ... rest of checks
}

This ensures the shorthand format is only used when a valid provider/model combination exists.

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.

3 participants