From 4ea44464a7890fd16defa5206a1d8326a6053905 Mon Sep 17 00:00:00 2001 From: larrykoo Date: Wed, 4 Mar 2026 21:28:28 +0800 Subject: [PATCH] refactor: move ThinkingLevel from AgentDefaults to ModelConfig Thinking is a model-level capability, not a global agent property. Per-model config avoids silent ignoring on non-Anthropic providers and eliminates spurious warning logs in multi-provider setups. Addresses PR #1076 review feedback from @yinwm. --- config/config.example.json | 6 +++--- pkg/agent/instance.go | 6 +++++- pkg/config/config.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/config.example.json b/config/config.example.json index 984eca6e2..12f515003 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -6,8 +6,7 @@ "model_name": "gpt4", "max_tokens": 8192, "temperature": 0.7, - "max_tool_iterations": 20, - "thinking_level": "" + "max_tool_iterations": 20 } }, "model_list": [ @@ -21,7 +20,8 @@ "model_name": "claude-sonnet-4.6", "model": "anthropic/claude-sonnet-4.6", "api_key": "sk-ant-your-key", - "api_base": "https://api.anthropic.com/v1" + "api_base": "https://api.anthropic.com/v1", + "thinking_level": "high" }, { "model_name": "gemini", diff --git a/pkg/agent/instance.go b/pkg/agent/instance.go index d25245951..1e18b6f64 100644 --- a/pkg/agent/instance.go +++ b/pkg/agent/instance.go @@ -104,7 +104,11 @@ func NewAgentInstance( temperature = *defaults.Temperature } - thinkingLevel := parseThinkingLevel(defaults.ThinkingLevel) + var thinkingLevelStr string + if mc, err := cfg.GetModelConfig(model); err == nil { + thinkingLevelStr = mc.ThinkingLevel + } + thinkingLevel := parseThinkingLevel(thinkingLevelStr) summarizeMessageThreshold := defaults.SummarizeMessageThreshold if summarizeMessageThreshold == 0 { diff --git a/pkg/config/config.go b/pkg/config/config.go index 9e31f9e3d..f85708ef0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -183,7 +183,6 @@ type AgentDefaults struct { SummarizeMessageThreshold int `json:"summarize_message_threshold" env:"PICOCLAW_AGENTS_DEFAULTS_SUMMARIZE_MESSAGE_THRESHOLD"` SummarizeTokenPercent int `json:"summarize_token_percent" env:"PICOCLAW_AGENTS_DEFAULTS_SUMMARIZE_TOKEN_PERCENT"` MaxMediaSize int `json:"max_media_size,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_MEDIA_SIZE"` - ThinkingLevel string `json:"thinking_level,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_THINKING_LEVEL"` } const DefaultMaxMediaSize = 20 * 1024 * 1024 // 20 MB @@ -506,6 +505,7 @@ type ModelConfig struct { RPM int `json:"rpm,omitempty"` // Requests per minute limit MaxTokensField string `json:"max_tokens_field,omitempty"` // Field name for max tokens (e.g., "max_completion_tokens") RequestTimeout int `json:"request_timeout,omitempty"` + ThinkingLevel string `json:"thinking_level,omitempty"` // Extended thinking: off|low|medium|high|xhigh|adaptive } // Validate checks if the ModelConfig has all required fields.