2026-06-28 23:03:57 +00:00
# pkg/persona
2026-06-30 20:40:37 +00:00
> Configurable personality system for LLM agents.
2026-06-28 23:03:57 +00:00
2026-06-30 20:40:37 +00:00
## Responsibility
2026-06-28 23:03:57 +00:00
2026-06-30 20:40:37 +00:00
Assemble the agent's final system prompt by combining:
2026-06-28 23:03:57 +00:00
2026-06-30 20:40:37 +00:00
1. **Base prompt** (hardcoded in the library)
2. **Persona YAML** (configurable per project)
3. **AGENTS.md** (project instructions, discovered by searching up the directory tree)
4. **Working memory context** (summaries if there's compaction)
2026-06-28 23:03:57 +00:00
2026-06-30 20:40:37 +00:00
## Public API
2026-06-28 23:03:57 +00:00
```go
type Persona struct {
2026-06-30 20:40:37 +00:00
ID string
Name string
Tone string
Style string
Language string
Constraints []string
FewShot []llm.Message
2026-06-28 23:03:57 +00:00
}
type Loader interface {
Load(ctx context.Context, configPath string) (Persona, error)
2026-06-30 20:40:37 +00:00
Discover(ctx context.Context, workdir string) (Persona, error) // includes AGENTS.md
2026-06-28 23:03:57 +00:00
}
```
2026-06-30 20:40:37 +00:00
## YAML format
2026-06-28 23:03:57 +00:00
```yaml
2026-06-30 20:40:37 +00:00
id: pragmatist
name: Pragmatist
tone: "Direct and professional"
style: "Idiomatic Go approach"
language: "English, with Spanish when needed"
2026-06-28 23:03:57 +00:00
constraints:
2026-06-30 20:40:37 +00:00
- "Don't use interface{} in new code (use any)"
- "Always wrap errors with %w"
2026-06-28 23:03:57 +00:00
few_shot:
- role: user
2026-06-30 20:40:37 +00:00
content: "Refactor this code"
2026-06-28 23:03:57 +00:00
- role: assistant
2026-06-30 20:40:37 +00:00
content: "Done. Optimized. Apply?"
2026-06-28 23:03:57 +00:00
```
## AGENTS.md discovery
2026-06-30 20:40:37 +00:00
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.
2026-06-28 23:03:57 +00:00
```
2026-06-30 20:40:37 +00:00
/home/user/project/AGENTS.md ← includes
/home/user/AGENTS.md ← includes
/home/AGENTS.md ← includes
~/.config/rony/AGENTS.md ← includes
2026-06-28 23:03:57 +00:00
```
2026-06-30 20:40:37 +00:00
## Usage
2026-06-28 23:03:57 +00:00
```go
2026-06-30 20:40:37 +00:00
p, err := persona.Discover(ctx, "/home/user/my-project")
// p.Content includes all of the above concatenated
2026-06-28 23:03:57 +00:00
```
2026-06-30 20:40:37 +00:00
## See also
2026-06-28 23:03:57 +00:00
2026-06-30 20:40:37 +00:00
- [pkg/agent ](../agent/README.md ) — Uses the persona in the system prompt