From 1b499c9b67be29766abc5df0912b9c9289623a83 Mon Sep 17 00:00:00 2001 From: Enmanuel Date: Fri, 10 Apr 2026 23:21:23 +0000 Subject: [PATCH] fix: resolver system_prompt_file relativo al directorio del config Antes, el runtime construia la ruta del system prompt como agents//, lo cual fallaba para agentes en agents/_specials/ (como Father Bot). Ahora: 1. config.Load() guarda el directorio del config en ConfigDir 2. llm.go usa ConfigDir para resolver rutas relativas Esto corrige que Father Bot operara sin su system prompt completo (369 lineas de instrucciones, pipeline, seguridad) usando solo la description de una linea como fallback. Co-Authored-By: Claude Opus 4.6 (1M context) --- devagents/llm.go | 4 ++-- internal/config/loader.go | 3 +++ internal/config/schema.go | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/devagents/llm.go b/devagents/llm.go index 6cd1762..eb84a96 100644 --- a/devagents/llm.go +++ b/devagents/llm.go @@ -29,8 +29,8 @@ func (a *Agent) runLLM(ctx context.Context, msgCtx decision.MessageContext, memK // Load system prompt from file if configured, else use description systemPrompt := a.cfg.Agent.Description if spFile := a.cfg.LLM.Reasoning.SystemPromptFile; spFile != "" { - // Resolve path relative to agent directory - spPath := filepath.Join("agents", a.cfg.Agent.ID, spFile) + // Resolve path relative to the config directory (handles _specials/ and custom locations) + spPath := filepath.Join(a.cfg.ConfigDir, spFile) if data, err := os.ReadFile(spPath); err == nil { systemPrompt = string(data) } else { diff --git a/internal/config/loader.go b/internal/config/loader.go index 4bf891f..30d5fff 100644 --- a/internal/config/loader.go +++ b/internal/config/loader.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "path/filepath" "gopkg.in/yaml.v3" ) @@ -26,6 +27,8 @@ func Load(path string) (*AgentConfig, error) { return nil, fmt.Errorf("invalid config %s: %w", path, err) } + cfg.ConfigDir = filepath.Dir(path) + return &cfg, nil } diff --git a/internal/config/schema.go b/internal/config/schema.go index 7cb03b4..089d8f5 100644 --- a/internal/config/schema.go +++ b/internal/config/schema.go @@ -16,6 +16,11 @@ type AgentConfig struct { Storage StorageCfg `yaml:"storage"` Memory MemoryCfg `yaml:"memory"` Skills SkillsCfg `yaml:"skills"` + + // ConfigDir is the directory containing the config file. Set by the loader + // at load time, not from YAML. Used to resolve relative paths like + // system_prompt_file correctly regardless of where the agent lives. + ConfigDir string `yaml:"-"` } // ── Identity ──────────────────────────────────────────────────────────────