From 0c6f93a1f46dcfc2816c62fb8844fc1e30787bf1 Mon Sep 17 00:00:00 2001 From: PierrunoYT Date: Fri, 6 Jun 2025 14:23:04 +0200 Subject: [PATCH] fix: properly detect environment variables and create default agents - Fix issue where ANTHROPIC_API_KEY and other provider env vars weren't being detected - Add logic to create default agents when no agents are configured - Ensure environment variables are properly applied during config initialization - Resolves timing issue between viper defaults and agent configuration --- internal/config/config.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 5a0905bb..5a23914c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -198,10 +198,23 @@ func Load(workingDir string, debug bool) (*Config, error) { cfg.Agents = make(map[AgentName]Agent) } + // If no agents were configured, set up default agents based on available providers + if len(cfg.Agents) == 0 { + agentNames := []AgentName{AgentCoder, AgentSummarizer, AgentTask, AgentTitle} + for _, agentName := range agentNames { + if setDefaultModelForAgent(agentName) { + logging.Info("created default agent configuration", "agent", agentName, "model", cfg.Agents[agentName].Model) + } + } + } + // Override the max tokens for title agent - cfg.Agents[AgentTitle] = Agent{ - Model: cfg.Agents[AgentTitle].Model, - MaxTokens: 80, + if titleAgent, exists := cfg.Agents[AgentTitle]; exists { + cfg.Agents[AgentTitle] = Agent{ + Model: titleAgent.Model, + MaxTokens: 80, + ReasoningEffort: titleAgent.ReasoningEffort, + } } return cfg, nil }