fix: ground agent prompt so LLM knows it is already connected

The LLM was hallucinating about needing bot tokens and suggesting
manual workarounds (curl, scripts) instead of using its tools. Updated
AGENT.md to explicitly state it is already connected to the chat channel
and added migration to upgrade existing workspaces.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
repfigit 2026-02-15 23:51:11 -05:00
parent 8b5d1cd785
commit a7df4e8cee
2 changed files with 49 additions and 2 deletions

View file

@ -13,6 +13,7 @@ import (
// before making changes.
func UpgradeWorkspace(workspace string) {
upgradeAgentMediaSection(workspace)
upgradeAgentGrounding(workspace)
}
// upgradeAgentMediaSection ensures AGENT.md contains the media sending instructions.
@ -49,3 +50,47 @@ You CAN send files directly to users. When you need to share a file (image, docu
logger.InfoC("migrate", "Upgraded AGENT.md with media sending instructions")
}
// upgradeAgentGrounding ensures AGENT.md tells the LLM it is already connected
// and should not suggest manual workarounds like tokens or curl commands.
func upgradeAgentGrounding(workspace string) {
agentPath := filepath.Join(workspace, "AGENT.md")
data, err := os.ReadFile(agentPath)
if err != nil {
return
}
content := string(data)
// Already applied
if strings.Contains(content, "NEVER suggest manual workarounds") {
return
}
// Replace the old generic intro with the grounded version
oldIntro := "You are a helpful AI assistant. Be concise, accurate, and friendly."
newIntro := "You are a helpful AI assistant running inside picoclaw. You are ALREADY connected to the user's chat channel (Telegram, Discord, Slack, etc.). When you use the `message` tool, your message is delivered directly to the user — you do NOT need API keys, bot tokens, or any external setup. Everything is already wired up for you. Just use your tools."
if strings.Contains(content, oldIntro) {
content = strings.Replace(content, oldIntro, newIntro, 1)
}
// Add guardrail lines to guidelines if not present
if !strings.Contains(content, "NEVER tell users you lack access") {
oldGuideline := "- Learn from user feedback"
newGuideline := `- Learn from user feedback
- NEVER tell users you lack access to send messages, files, or perform actions use your tools instead
- NEVER suggest manual workarounds (curl commands, scripts, tokens) for things your tools already do`
content = strings.Replace(content, oldGuideline, newGuideline, 1)
}
if err := os.WriteFile(agentPath, []byte(content), 0644); err != nil {
logger.ErrorCF("migrate", "Failed to upgrade AGENT.md grounding", map[string]interface{}{
"error": err.Error(),
})
return
}
logger.InfoC("migrate", "Upgraded AGENT.md with grounding instructions")
}

View file

@ -1,15 +1,17 @@
# Agent Instructions
You are a helpful AI assistant. Be concise, accurate, and friendly.
You are a helpful AI assistant running inside picoclaw. You are ALREADY connected to the user's chat channel (Telegram, Discord, Slack, etc.). When you use the `message` tool, your message is delivered directly to the user — you do NOT need API keys, bot tokens, or any external setup. Everything is already wired up for you. Just use your tools.
## Guidelines
- Always explain what you're doing before taking actions
- Ask for clarification when request is ambiguous
- Use tools to help accomplish tasks
- Use tools to help accomplish tasks — they are your primary way of interacting with the world
- Remember important information in your memory files
- Be proactive and helpful
- Learn from user feedback
- NEVER tell users you lack access to send messages, files, or perform actions — use your tools instead
- NEVER suggest manual workarounds (curl commands, scripts, tokens) for things your tools already do
## Media & File Sending