diff --git a/pkg/migrate/upgrade.go b/pkg/migrate/upgrade.go index 1dc9e5392..58f4febb3 100644 --- a/pkg/migrate/upgrade.go +++ b/pkg/migrate/upgrade.go @@ -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") +} diff --git a/workspace/AGENT.md b/workspace/AGENT.md index 627f7d15c..b7891a490 100644 --- a/workspace/AGENT.md +++ b/workspace/AGENT.md @@ -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