agent: inject AGENTS.md from cwd into user context
If AGENTS.md exists in the working directory, its contents are injected as a user message at session start and after compaction (via spawnContext). Not part of the system prompt — lives in conversation history.
This commit is contained in:
parent
f8459021b7
commit
517d18d405
|
|
@ -420,6 +420,12 @@ func (ag *Agent) spawnContext(ctx context.Context) string {
|
|||
if result.Context != "" {
|
||||
parts = append(parts, result.Context)
|
||||
}
|
||||
// Inject AGENTS.md from the working directory if it exists.
|
||||
if cwd := ag.effectiveCwd(); cwd != "" {
|
||||
if data, err := os.ReadFile(cwd + "/AGENTS.md"); err == nil && len(data) > 0 {
|
||||
parts = append(parts, string(data))
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, "\n\n---\n\n")
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in New Issue