5047a321d2
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
82 lines
2.7 KiB
Markdown
82 lines
2.7 KiB
Markdown
# 0047 — System prompt no se carga para agentes en _specials/
|
|
|
|
## Objetivo
|
|
|
|
El runtime resuelve la ruta del `system_prompt_file` como `agents/<agent-id>/prompts/system.md`,
|
|
pero los agentes especiales (Father Bot, etc.) viven en `agents/_specials/<agent-id>/`. Resultado:
|
|
el system prompt no se carga y el agente usa solo la `description` como prompt.
|
|
|
|
## Contexto
|
|
|
|
En `devagents/llm.go:33`, la ruta se construye asi:
|
|
|
|
```go
|
|
spPath := filepath.Join("agents", a.cfg.Agent.ID, spFile)
|
|
```
|
|
|
|
Esto produce `agents/father-bot/prompts/system.md` para Father Bot, pero el archivo real esta en
|
|
`agents/_specials/father-bot/prompts/system.md`.
|
|
|
|
Los logs confirman el problema:
|
|
```json
|
|
{"msg":"failed to load system_prompt_file, using description","path":"agents/father-bot/prompts/system.md"}
|
|
```
|
|
|
|
**Impacto**: Father Bot opera sin su system prompt completo (369 lineas de instrucciones, pipeline,
|
|
seguridad) y solo usa la description de una linea del config.yaml. Esto degrada severamente su
|
|
comportamiento.
|
|
|
|
## Arquitectura
|
|
|
|
- `internal/config/schema.go` — MODIFICAR: agregar campo `ConfigDir` a `AgentConfig`
|
|
- `internal/config/loader.go` — MODIFICAR: poblar `ConfigDir` con el directorio del config
|
|
- `devagents/llm.go` — MODIFICAR: usar `ConfigDir` en vez de hardcodear `agents/<id>`
|
|
|
|
No hay cambios en `pkg/` (puro). Los cambios son en el loader (impuro) y runtime (impuro).
|
|
|
|
## Tareas
|
|
|
|
### Fase 1: Fix
|
|
|
|
- [ ] 1.1 Agregar campo `ConfigDir string` (no YAML, solo runtime) a `AgentConfig`
|
|
- [ ] 1.2 En `config.Load()`, poblar `ConfigDir` con `filepath.Dir(path)`
|
|
- [ ] 1.3 En `devagents/llm.go`, usar `a.cfg.ConfigDir` para resolver `system_prompt_file`
|
|
|
|
### Fase 2: Tests
|
|
|
|
- [ ] 2.1 Test unitario que verifica que `Load()` puebla `ConfigDir`
|
|
- [ ] 2.2 `go build -tags goolm ./...` compila sin errores
|
|
- [ ] 2.3 `go test -tags goolm ./...` pasa sin errores
|
|
|
|
### Fase 3: Docs
|
|
|
|
- [ ] 3.1 Cerrar issue, mover a completed
|
|
|
|
## Ejemplo de uso
|
|
|
|
Antes (roto):
|
|
```
|
|
config en: agents/_specials/father-bot/config.yaml
|
|
system_prompt_file: prompts/system.md
|
|
resuelve: agents/father-bot/prompts/system.md ← NO EXISTE
|
|
resultado: usa description como fallback
|
|
```
|
|
|
|
Despues (correcto):
|
|
```
|
|
config en: agents/_specials/father-bot/config.yaml
|
|
ConfigDir: agents/_specials/father-bot
|
|
system_prompt_file: prompts/system.md
|
|
resuelve: agents/_specials/father-bot/prompts/system.md ← CORRECTO
|
|
```
|
|
|
|
## Decisiones de diseno
|
|
|
|
1. **`ConfigDir` como campo runtime**: no se serializa en YAML (`yaml:"-"`), se puebla
|
|
automaticamente por el loader. Cero impacto en configs existentes.
|
|
2. **Genérico**: el fix funciona para cualquier agente en cualquier ubicacion, no solo _specials.
|
|
|
|
## Riesgos
|
|
|
|
- Bajo riesgo: cambio minimo y auto-contenido. El campo nuevo es backward-compatible.
|