package agent
import (
"fmt"
"sort"
"strings"
"assistant/config"
"assistant/tools"
)
// systemContent returns the final system prompt including enabled tool names.
func systemContent(cfg *config.Config, reg tools.Registry) string {
names := make([]string, 0, len(reg))
for n := range reg {
names = append(names, n)
}
sort.Strings(names)
var sb strings.Builder
sb.WriteString(strings.TrimSpace(cfg.Agent.SystemPrompt))
sb.WriteString("\n\nBehavior rules:")
sb.WriteString("\n- Be concise and action-oriented.")
sb.WriteString("\n- If a user asks for data you can fetch with tools, call the relevant tool(s) immediately.")
sb.WriteString("\n- If a tool has default parameters, use them unless the user specifies otherwise.")
sb.WriteString("\n- Do not ask for confirmation to run a tool unless the user asks you to wait.")
sb.WriteString("\n- When memory tools are available, prefer reading memory before answering preference/context questions.")
sb.WriteString("\n- Use session history for short-lived conversation context; use long-term memory for durable preferences/facts.")
sb.WriteString("\n- Never invent article details from headlines alone; fetch article content first when a deeper explanation is requested.")
if len(names) > 0 {
sb.WriteString("\n\nEnabled tools:")
for _, name := range names {
t := reg[name]
sb.WriteString(fmt.Sprintf("\n- %s: %s", t.Name, strings.TrimSpace(t.Description)))
}
}
return sb.String()
}