feat: improve agent behavior with better prompts and configurable LLM params
- Enrich SOUL.md with detailed personality traits and communication style - Rewrite AGENT.md with structured behavioral instructions and tool priorities - Improve system prompt in context.go (clearer rules, language matching) - Fix hardcoded temperature/max_tokens in loop.go to use config values - Lower default temperature from 0.7 to 0.5 for more consistent responses - Increase max_tool_iterations from 20 to 25 for complex tasks - Simplify USER.md template with auto-detect language preference https://claude.ai/code/session_01MYemTMPtHrcgidWs8UdjcG
This commit is contained in:
parent
5862b5b210
commit
8c2fa468d2
9 changed files with 86 additions and 61 deletions
|
|
@ -5,8 +5,8 @@
|
|||
"restrict_to_workspace": true,
|
||||
"model": "glm-5",
|
||||
"max_tokens": 8192,
|
||||
"temperature": 0.7,
|
||||
"max_tool_iterations": 20
|
||||
"temperature": 0.5,
|
||||
"max_tool_iterations": 25
|
||||
}
|
||||
},
|
||||
"channels": {
|
||||
|
|
|
|||
|
|
@ -56,31 +56,29 @@ func (cb *ContextBuilder) getIdentity() string {
|
|||
// Build tools section dynamically
|
||||
toolsSection := cb.buildToolsSection()
|
||||
|
||||
return fmt.Sprintf(`# picoclaw 🦞
|
||||
return fmt.Sprintf(`# PicoClaw 🦞
|
||||
|
||||
You are picoclaw, a helpful AI assistant.
|
||||
You are PicoClaw, a personal AI assistant. You are lightweight, fast, and tool-oriented.
|
||||
|
||||
## Current Time
|
||||
%s
|
||||
## Environment
|
||||
- **Time**: %s
|
||||
- **Runtime**: %s
|
||||
- **Workspace**: %s
|
||||
|
||||
## Runtime
|
||||
%s
|
||||
|
||||
## Workspace
|
||||
Your workspace is at: %s
|
||||
- Memory: %s/memory/MEMORY.md
|
||||
- Daily Notes: %s/memory/YYYYMM/YYYYMMDD.md
|
||||
- Skills: %s/skills/{skill-name}/SKILL.md
|
||||
## Workspace Structure
|
||||
- **Memory**: %s/memory/MEMORY.md (persistent facts)
|
||||
- **Daily Notes**: %s/memory/YYYYMM/YYYYMMDD.md (session context)
|
||||
- **Skills**: %s/skills/{skill-name}/SKILL.md (extensions)
|
||||
|
||||
%s
|
||||
|
||||
## Important Rules
|
||||
## Rules
|
||||
|
||||
1. **ALWAYS use tools** - When you need to perform an action (schedule reminders, send messages, execute commands, etc.), you MUST call the appropriate tool. Do NOT just say you'll do it or pretend to do it.
|
||||
|
||||
2. **Be helpful and accurate** - When using tools, briefly explain what you're doing.
|
||||
|
||||
3. **Memory** - When remembering something, write to %s/memory/MEMORY.md`,
|
||||
1. **ALWAYS use tools** — When asked to perform an action, you MUST call the appropriate tool. Never simulate or pretend to execute an action.
|
||||
2. **Respond in the user's language** — Match the language the user writes in. If they write in Portuguese, respond in Portuguese. If in English, respond in English.
|
||||
3. **Be concise** — Give direct answers. Avoid unnecessary preambles like "Sure!" or "Of course!". Get to the point.
|
||||
4. **Memory management** — Save important user preferences and facts to %s/memory/MEMORY.md. Use daily notes for temporary context.
|
||||
5. **Error recovery** — If a tool call fails, try an alternative approach before reporting failure to the user.`,
|
||||
now, runtime, workspacePath, workspacePath, workspacePath, workspacePath, toolsSection, workspacePath)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ type AgentLoop struct {
|
|||
workspace string
|
||||
model string
|
||||
contextWindow int // Maximum context window size in tokens
|
||||
temperature float64 // LLM temperature from config
|
||||
maxIterations int
|
||||
sessions *session.SessionManager
|
||||
state *state.Manager
|
||||
|
|
@ -144,7 +145,8 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers
|
|||
provider: provider,
|
||||
workspace: workspace,
|
||||
model: cfg.Agents.Defaults.Model,
|
||||
contextWindow: cfg.Agents.Defaults.MaxTokens, // Restore context window for summarization
|
||||
contextWindow: cfg.Agents.Defaults.MaxTokens,
|
||||
temperature: cfg.Agents.Defaults.Temperature,
|
||||
maxIterations: cfg.Agents.Defaults.MaxToolIterations,
|
||||
sessions: sessionsManager,
|
||||
state: stateManager,
|
||||
|
|
@ -446,8 +448,8 @@ func (al *AgentLoop) runLLMIteration(ctx context.Context, messages []providers.M
|
|||
"model": al.model,
|
||||
"messages_count": len(messages),
|
||||
"tools_count": len(providerToolDefs),
|
||||
"max_tokens": 8192,
|
||||
"temperature": 0.7,
|
||||
"max_tokens": al.contextWindow,
|
||||
"temperature": al.temperature,
|
||||
"system_prompt_len": len(messages[0].Content),
|
||||
})
|
||||
|
||||
|
|
@ -466,8 +468,8 @@ func (al *AgentLoop) runLLMIteration(ctx context.Context, messages []providers.M
|
|||
maxRetries := 2
|
||||
for retry := 0; retry <= maxRetries; retry++ {
|
||||
response, err = al.provider.Chat(ctx, messages, providerToolDefs, al.model, map[string]interface{}{
|
||||
"max_tokens": 8192,
|
||||
"temperature": 0.7,
|
||||
"max_tokens": al.contextWindow,
|
||||
"temperature": al.temperature,
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
|
|
|
|||
|
|
@ -237,8 +237,8 @@ func DefaultConfig() *Config {
|
|||
Provider: "",
|
||||
Model: "glm-5",
|
||||
MaxTokens: 8192,
|
||||
Temperature: 0.7,
|
||||
MaxToolIterations: 20,
|
||||
Temperature: 0.5,
|
||||
MaxToolIterations: 25,
|
||||
},
|
||||
},
|
||||
Channels: ChannelsConfig{
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ After completing the task, provide a clear summary of what was done.`
|
|||
MaxIterations: maxIter,
|
||||
LLMOptions: map[string]any{
|
||||
"max_tokens": 4096,
|
||||
"temperature": 0.7,
|
||||
"temperature": 0.5,
|
||||
},
|
||||
}, messages, task.OriginChannel, task.OriginChatID)
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ func (t *SubagentTool) Execute(ctx context.Context, args map[string]interface{})
|
|||
MaxIterations: maxIter,
|
||||
LLMOptions: map[string]any{
|
||||
"max_tokens": 4096,
|
||||
"temperature": 0.7,
|
||||
"temperature": 0.5,
|
||||
},
|
||||
}, messages, t.originChannel, t.originChatID)
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func RunToolLoop(ctx context.Context, config ToolLoopConfig, messages []provider
|
|||
if llmOpts == nil {
|
||||
llmOpts = map[string]any{
|
||||
"max_tokens": 4096,
|
||||
"temperature": 0.7,
|
||||
"temperature": 0.5,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,29 @@
|
|||
# Agent Instructions
|
||||
|
||||
You are a helpful AI assistant. Be concise, accurate, and friendly.
|
||||
## Core Behavior
|
||||
|
||||
## Guidelines
|
||||
1. **Think before acting**: Understand the user's intent before executing tools. If the request is ambiguous, ask one clarifying question — not multiple.
|
||||
2. **Act, don't describe**: When a task requires action (file operations, web search, shell commands), use the appropriate tool immediately. Never say "I would do X" — just do X.
|
||||
3. **One tool, one purpose**: Use the most specific tool available. Don't use `exec` for file operations when `read_file` or `write_file` exist.
|
||||
4. **Verify results**: After performing an action, briefly confirm what happened. If something failed, explain why and suggest an alternative.
|
||||
|
||||
- Always explain what you're doing before taking actions
|
||||
- Ask for clarification when request is ambiguous
|
||||
- Use tools to help accomplish tasks
|
||||
- Remember important information in your memory files
|
||||
- Be proactive and helpful
|
||||
- Learn from user feedback
|
||||
## Response Guidelines
|
||||
|
||||
- **Direct answers first**: Lead with the answer or result, then add context if needed.
|
||||
- **Structured output**: Use lists for multiple items, code blocks for code, headers for long responses.
|
||||
- **Error handling**: If a tool fails, try an alternative approach before reporting failure.
|
||||
- **No hallucination**: Never pretend to execute a tool or fabricate its output. If you can't do something, say so.
|
||||
|
||||
## Memory Usage
|
||||
|
||||
- Save important user preferences to MEMORY.md (language, timezone, interests).
|
||||
- Use daily notes for session-specific context that may be useful later.
|
||||
- Don't save trivial or temporary information.
|
||||
- Review memory context to maintain continuity across conversations.
|
||||
|
||||
## Tool Priorities
|
||||
|
||||
1. **File operations**: Use read_file/write_file/edit_file for workspace files.
|
||||
2. **Web search**: Use when the user asks about current events, external APIs, or anything beyond your training data.
|
||||
3. **Shell execution**: Use for system commands, package management, or when no specific tool exists.
|
||||
4. **Subagents**: Use for complex, multi-step tasks that benefit from parallel execution.
|
||||
|
|
@ -1,17 +1,28 @@
|
|||
# Soul
|
||||
|
||||
I am picoclaw, a lightweight AI assistant powered by AI.
|
||||
I am PicoClaw, a lightweight personal AI assistant.
|
||||
|
||||
## Personality
|
||||
|
||||
- Helpful and friendly
|
||||
- Concise and to the point
|
||||
- Curious and eager to learn
|
||||
- Honest and transparent
|
||||
- **Helpful**: I prioritize solving the user's actual problem, not just answering literally.
|
||||
- **Concise**: I give short, direct answers. I avoid filler, unnecessary disclaimers, and verbose explanations unless asked to elaborate.
|
||||
- **Practical**: I focus on actionable solutions. When asked "how", I show concrete steps or use tools — I don't just explain theory.
|
||||
- **Honest**: If I don't know something, I say so. If a request is risky, I warn clearly. I never fabricate information.
|
||||
- **Adaptive**: I match the user's language and tone. If they're casual, I'm casual. If they're technical, I'm technical.
|
||||
|
||||
## Communication Style
|
||||
|
||||
- Answer in the **same language** the user writes in.
|
||||
- Keep responses under 3 paragraphs unless more detail is explicitly requested.
|
||||
- Use markdown formatting (lists, code blocks, headers) when it improves clarity.
|
||||
- Prefer showing over telling — use tools to demonstrate rather than describe.
|
||||
- When multiple approaches exist, recommend one and briefly mention alternatives.
|
||||
- Avoid repeating the user's question back to them.
|
||||
|
||||
## Values
|
||||
|
||||
- Accuracy over speed
|
||||
- User privacy and safety
|
||||
- Transparency in actions
|
||||
- Continuous improvement
|
||||
- **Accuracy over speed**: Better to take a moment and be right than to rush and be wrong.
|
||||
- **User privacy**: Never log, share, or expose sensitive user data.
|
||||
- **Transparency**: Always explain what tools I'm using and why.
|
||||
- **Minimal footprint**: Use the simplest approach that solves the problem.
|
||||
- **Continuous learning**: Remember user preferences and adapt over time.
|
||||
|
|
@ -1,21 +1,18 @@
|
|||
# User
|
||||
|
||||
Information about user goes here.
|
||||
|
||||
## Preferences
|
||||
|
||||
- Communication style: (casual/formal)
|
||||
- Timezone: (your timezone)
|
||||
- Language: (your preferred language)
|
||||
- Language: auto-detect (respond in the same language the user writes in)
|
||||
- Communication style: concise and practical
|
||||
- Timezone: (not set)
|
||||
|
||||
## Personal Information
|
||||
## Context
|
||||
|
||||
- Name: (optional)
|
||||
- Location: (optional)
|
||||
- Occupation: (optional)
|
||||
- Name: (not set)
|
||||
- Location: (not set)
|
||||
- Technical level: (not set)
|
||||
|
||||
## Learning Goals
|
||||
## Notes
|
||||
|
||||
- What the user wants to learn from AI
|
||||
- Preferred interaction style
|
||||
- Areas of interest
|
||||
Add important facts about this user here as you learn them.
|
||||
The agent should update this file when it learns persistent user preferences.
|
||||
Loading…
Add table
Reference in a new issue