Skip to content

fix(agent): resolve thinking level from model refs#2336

Open
xiwuqi wants to merge 1 commit intosipeed:mainfrom
xiwuqi:wuxi/fix-thinking-level-model-ref
Open

fix(agent): resolve thinking level from model refs#2336
xiwuqi wants to merge 1 commit intosipeed:mainfrom
xiwuqi:wuxi/fix-thinking-level-model-ref

Conversation

@xiwuqi
Copy link
Copy Markdown
Contributor

@xiwuqi xiwuqi commented Apr 4, 2026

📝 Description

Fixes the thinking_level lookup bug behind #2286: when an agent's primary model is configured via a model reference instead of a model_name alias, PicoClaw initializes the agent with ThinkingOff even though the referenced model_list entry has thinking_level configured.

Problem summary:

  • NewAgentInstance() resolves the agent model reference from config.
  • It then tries to read thinking_level using cfg.GetModelConfig(model).
  • GetModelConfig() only matches model_name, so a primary value like anthropic/claude-sonnet-4.6 or claude-sonnet-4.6 misses the correct model_list entry.
  • The agent therefore starts with ThinkingOff instead of the configured level.

Root cause:

  • This path used a lookup helper that only accepts model_name aliases.
  • But agent model references are already allowed to be aliases, full protocol/model strings, or bare model IDs.
  • The thinking-level lookup was narrower than the rest of the model-resolution path.

What changed:

  • Reuse lookupModelConfigByRef() when initializing ThinkingLevel in NewAgentInstance().
  • Add a regression test that covers both a full protocol reference and a bare model ID pointing at the same model_list entry.

Why this fix:

  • It is the smallest targeted fix for #2286.
  • It aligns thinking_level initialization with the existing model candidate resolution logic.
  • I considered broadening GetModelConfig() to accept model references globally, but that would widen semantics and risk beyond this bug.

Risk / compatibility:

  • Low risk. This only affects how ThinkingLevel is initialized when the configured primary model is given as a model reference instead of a model_name alias.
  • Alias-based configs keep the same behavior.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

Fixes #2286

📚 Technical Context (Skip for Docs)

🧪 Test Environment

  • Hardware: PC
  • OS: Windows (local development environment)
  • Model/Provider: N/A (unit tests with mock provider)
  • Channels: N/A

📸 Evidence (Optional)

Click to view Logs/Screenshots

Passed:

  • go test ./pkg/agent -run TestNewAgentInstance_ResolvesThinkingLevelFromModelReference -count=1
  • go test ./pkg/agent -run TestNewAgentInstance_|TestParseThinkingLevel -count=1

Baseline reproduction:

  • The new regression test fails on clean upstream/main before this fix.
  • In that baseline run, ThinkingLevel is off for both anthropic/claude-sonnet-4.6 and claude-sonnet-4.6, even though the referenced model_list entry sets thinking_level = high.

Additional notes:

  • go test ./pkg/agent -count=1 still fails due to pre-existing TestGlobalSkillFileContentChange; I confirmed the same failure on clean upstream/main, so it is unrelated to this PR.
  • codex review --base origin/main could not run in this environment because the local Codex config rejected approvals_reviewer = never.

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: agent go Pull requests that update go code labels Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: agent go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]Impossible to read thinking_level from config when model and model_name are different

1 participant