From f2b9ed007c1fed6446697f7ceb746aea9d40c1e3 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Mon, 14 Jul 2025 20:05:46 +0200 Subject: [PATCH] fix: agent init --- internal/config/config.go | 31 +++++++++++++++++ internal/config/load.go | 34 +------------------ internal/tui/components/chat/splash/splash.go | 1 + internal/tui/util/util.go | 2 ++ 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index ae8bcfdc35562e680527e99cdc74fd591e849874..5108a5cbee1684b92f779243b35aa3a50f162e60 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -371,3 +371,34 @@ func (c *Config) SetProviderAPIKey(providerID, apiKey string) error { c.Providers[providerID] = providerConfig return nil } + +func (c *Config) SetupAgents() { + agents := map[string]Agent{ + "coder": { + ID: "coder", + Name: "Coder", + Description: "An agent that helps with executing coding tasks.", + Model: SelectedModelTypeLarge, + ContextPaths: c.Options.ContextPaths, + // All tools allowed + }, + "task": { + ID: "task", + Name: "Task", + Description: "An agent that helps with searching for context and finding implementation details.", + Model: SelectedModelTypeLarge, + ContextPaths: c.Options.ContextPaths, + AllowedTools: []string{ + "glob", + "grep", + "ls", + "sourcegraph", + "view", + }, + // NO MCPs or LSPs by default + AllowedMCP: map[string][]string{}, + AllowedLSP: []string{}, + }, + } + c.Agents = agents +} diff --git a/internal/config/load.go b/internal/config/load.go index 9f2b5e55f1ccc0a687d46083b67e81d6e5fa212a..d80a1ebfccddc509e983a6bc17084931c2a7dec3 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -83,37 +83,7 @@ func Load(workingDir string, debug bool) (*Config, error) { if err := cfg.configureSelectedModels(providers); err != nil { return nil, fmt.Errorf("failed to configure selected models: %w", err) } - - // TODO: remove the agents concept from the config - agents := map[string]Agent{ - "coder": { - ID: "coder", - Name: "Coder", - Description: "An agent that helps with executing coding tasks.", - Model: SelectedModelTypeLarge, - ContextPaths: cfg.Options.ContextPaths, - // All tools allowed - }, - "task": { - ID: "task", - Name: "Task", - Description: "An agent that helps with searching for context and finding implementation details.", - Model: SelectedModelTypeLarge, - ContextPaths: cfg.Options.ContextPaths, - AllowedTools: []string{ - "glob", - "grep", - "ls", - "sourcegraph", - "view", - }, - // NO MCPs or LSPs by default - AllowedMCP: map[string][]string{}, - AllowedLSP: []string{}, - }, - } - cfg.Agents = agents - + cfg.SetupAgents() return cfg, nil } @@ -387,8 +357,6 @@ func (cfg *Config) configureSelectedModels(knownProviders []provider.Provider) e large.Provider = largeModelSelected.Provider } model := cfg.GetModel(large.Provider, large.Model) - slog.Info("Configuring selected large model", "provider", large.Provider, "model", large.Model) - slog.Info("Model configured", "model", model) if model == nil { large = defaultLarge // override the model type to large diff --git a/internal/tui/components/chat/splash/splash.go b/internal/tui/components/chat/splash/splash.go index 722aaea6f75c6ef0bef7e0a9ec2de319c6d71bfb..5b343e6c5538cc17b476e521e6f2bfaf6b3490cb 100644 --- a/internal/tui/components/chat/splash/splash.go +++ b/internal/tui/components/chat/splash/splash.go @@ -313,6 +313,7 @@ func (s *splashCmp) setPreferredModel(selectedItem models.ModelOption) tea.Cmd { return util.ReportError(err) } } + cfg.SetupAgents() return nil } diff --git a/internal/tui/util/util.go b/internal/tui/util/util.go index d737acb3f06a155ab52cc7eed7d32a634d85d582..1f4ea30c49c8fb0517a5068d3b7f05970638743a 100644 --- a/internal/tui/util/util.go +++ b/internal/tui/util/util.go @@ -1,6 +1,7 @@ package util import ( + "log/slog" "time" tea "github.com/charmbracelet/bubbletea/v2" @@ -22,6 +23,7 @@ func CmdHandler(msg tea.Msg) tea.Cmd { } func ReportError(err error) tea.Cmd { + slog.Error("Error reported", "error", err) return CmdHandler(InfoMsg{ Type: InfoTypeError, Msg: err.Error(),