Export persona.DiscoverAgentsMD and add agent.Config.AgentsMD so project and global AGENTS.md rules actually reach the model. Previously buildInitialMessages always called AssembleSystemPrompt with an empty string, so no AGENTS.md content was ever injected despite the discovery logic already existing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| loader.go | ||
| persona.go | ||
| persona_test.go | ||
| README.es.md | ||
| README.md | ||
pkg/persona
Configurable personality system for LLM agents.
Responsibility
Assemble the agent's final system prompt by combining:
- Base prompt (hardcoded in the library)
- Persona YAML (configurable per project)
- AGENTS.md (project instructions, discovered by searching up the directory tree)
- Working memory context (summaries if there's compaction)
Public API
type Persona struct {
ID string
Name string
Tone string
Style string
Language string
Constraints []string
FewShot []llm.Message
}
type Loader interface {
Load(ctx context.Context, configPath string) (Persona, error)
Discover(ctx context.Context, workdir string) (Persona, error) // includes AGENTS.md
}
YAML format
id: pragmatist
name: Pragmatist
tone: "Direct and professional"
style: "Idiomatic Go approach"
language: "English, with Spanish when needed"
constraints:
- "Don't use interface{} in new code (use any)"
- "Always wrap errors with %w"
few_shot:
- role: user
content: "Refactor this code"
- role: assistant
content: "Done. Optimized. Apply?"
AGENTS.md discovery
The loader searches for ./AGENTS.md, walks up to the parent directory, etc., concatenating all found until reaching ~ or /. Also includes ~/.config/rony/AGENTS.md as a global default.
/home/user/project/AGENTS.md ← includes
/home/user/AGENTS.md ← includes
/home/AGENTS.md ← includes
~/.config/rony/AGENTS.md ← includes
Usage
p, err := persona.Discover(ctx, "/home/user/my-project")
// p.Content includes all of the above concatenated
See also
- pkg/agent — Uses the persona in the system prompt