Skip to content

Fix cron reminder phrasing and improve MCP tool visibility/status on long-running instances#2470

Open
dsus4wang wants to merge 3 commits intosipeed:mainfrom
dsus4wang:fix-cron-job
Open

Fix cron reminder phrasing and improve MCP tool visibility/status on long-running instances#2470
dsus4wang wants to merge 3 commits intosipeed:mainfrom
dsus4wang:fix-cron-job

Conversation

@dsus4wang
Copy link
Copy Markdown

@dsus4wang dsus4wang commented Apr 10, 2026

📝 Description

This PR includes two related improvements around cron authoring and MCP runtime behavior.

For normal cron jobs, the saved message is replayed into the agent loop as a fresh user-style input when the job fires. This updates the cron tool prompt/schema guidance so agents prefer first-person or direct-address wording such as tell me, remind me, and do not reply if nothing changed, instead of third-person wording like notify the user. The related cron guide and both the English and Chinese tool configuration docs are updated with clearer wording and examples.

This PR also fixes MCP behavior during config reload. Previously, reload could preserve stale MCP registrations from the old runtime, which meant MCP config changes were not fully applied until process restart. Reload now rebuilds MCP tools from the new config, removes tools for deleted servers, and clears stale MCP state when MCP servers are removed. In addition, a /list mcp command is added so the current MCP connection/status summary can be inspected from the command layer.

🗣️ Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

N/A

📚 Technical Context (Skip for Docs)

  • Reference URL: N/A
  • Reasoning: Normal cron jobs send payload.message back into the agent loop as a fresh input, so third-person wording like notify the user can produce awkward third-person replies. Updating the cron tool guidance and docs helps the agent generate job messages in a user-facing style that produces better downstream responses.
  • Reasoning: MCP reload previously reused old runtime registrations instead of rebuilding from the new config. That could leave removed MCP tools active and prevent newly configured MCP servers or updated endpoints from taking effect until restart. Reload now reconstructs MCP state from the new config and exposes /list mcp for easier verification.

🧪 Test Environment

  • Hardware: PC
  • OS: Linux amd64
  • Model/Provider: N/A
  • Channels: N/A

📸 Evidence (Optional)

Click to view Logs/Screenshots
/usr/local/go/bin/go test ./pkg/agent ./pkg/commands
ok  	github.com/sipeed/picoclaw/pkg/agent	15.235s
ok  	github.com/sipeed/picoclaw/pkg/commands	0.005s
</details>

## ☑️ Checklist
- [x] My code/docs follow the style of this project.
- [x] I have performed a self-review of my own changes.
- [x] I have updated the documentation accordingly.

- clarify that normal cron messages are replayed as user-style inputs
- instruct agents to prefer first-person/direct-address wording
- document recommended wording and examples in cron docs
- add matching guidance to English and Chinese tool configuration docs
Copilot AI review requested due to automatic review settings April 10, 2026 06:23
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 10, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates cron tool and documentation guidance so that non-command cron job message values are written as user-perspective inputs (since they are replayed into the agent loop as a new user-style message when the job fires).

Changes:

  • Updated the cron tool description and message parameter schema description to recommend first-person/direct-address wording for normal (non-command) cron jobs.
  • Added/expanded cron documentation guidance (including examples) about writing job messages to avoid third-person phrasing.
  • Updated tool configuration docs (EN + ZH) to reflect the “message is replayed as user input” behavior and recommended wording.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/tools/cron.go Improves LLM-facing tool prompt/schema guidance for cron message phrasing in normal jobs.
docs/tools_configuration.md Adds guidance on writing cron message from the user’s perspective for non-command jobs.
docs/zh/tools_configuration.md Adds the same guidance in Chinese for non-command cron job message phrasing.
docs/cron.md Adds a dedicated “Writing Job Messages” section with recommended style and examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 232 to +237
| 配置项 | 类型 | 默认值 | 描述 |
|------------------------|------|--------|-------------------------------------|
| `exec_timeout_minutes` | int | 5 | 执行超时时间(分钟),0 表示无限制 |
| `allow_command` | bool | false | 允许 cron 任务执行 shell 命令 |

对于不带 `command` 的普通 cron 任务,保存下来的 `message` 会在任务触发时重新作为一条新的“用户消息”送回 agent。编写时应使用用户视角/直接对 agent 说话的口吻,例如 `每小时检查仓库更新,如果有新版本告诉我`,而不是 `如果有更新就通知用户`。
Copilot AI review requested due to automatic review settings April 10, 2026 12:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates user-facing guidance for cron job message wording so scheduled “normal” jobs read like user prompts when replayed into the agent loop, and it also introduces MCP status plumbing surfaced via a new /list mcp command plus MCP reload re-initialization support.

Changes:

  • Refine cron tool prompt/schema + docs to recommend first-person/direct-address message phrasing for non-command jobs.
  • Add /list mcp subcommand and runtime callback to display MCP server status.
  • Rework MCP manager/tool registration to support config reloads and provide a formatted status snapshot (with added tests).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/tools/cron.go Updates cron tool description/schema guidance for user-perspective job messages.
pkg/commands/runtime.go Adds GetMCPStatus callback to command runtime dependencies.
pkg/commands/cmd_list.go Adds /list mcp subcommand that replies with MCP status.
pkg/commands/show_list_handlers_test.go Extends list handler tests to cover /list mcp.
pkg/commands/builtin_test.go Updates /help expectations and adds test for /list mcp.
pkg/agent/loop.go Initializes MCP on reload, wires command runtime to formatted MCP status, closes old MCP manager.
pkg/agent/loop_mcp.go Refactors MCP runtime tracking + adds status formatting and shared MCP registration helpers.
pkg/agent/loop_test.go Adds reload + status formatting tests using a fake MCP controller.
docs/tools_configuration.md Documents cron message phrasing guidance for normal (non-command) jobs.
docs/zh/tools_configuration.md Chinese documentation update for the same cron message guidance.
docs/cron.md Expands cron guide with a “Writing Job Messages” section and examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 3509 to +3512
ListDefinitions: al.cmdRegistry.Definitions,
GetMCPStatus: func() string {
return formatMCPStatus(cfg, al.mcp.statusSnapshot())
},
Comment on lines +67 to +75
{
Name: "mcp",
Description: "MCP server status",
Handler: func(_ context.Context, req Request, rt *Runtime) error {
if rt == nil || rt.GetMCPStatus == nil {
return req.Reply(unavailableMsg)
}
return req.Reply(rt.GetMCPStatus())
},
@afjcjsbx
Copy link
Copy Markdown
Collaborator

Hi, the PR involves two different aspects, cron and /list mcp, maybe you mixed the two features, what is the intent of this PR?

@dsus4wang dsus4wang changed the title improve cron prompt guidance for user-perspective job messages Fix cron reminder phrasing and improve MCP tool visibility/status on long-running instances Apr 11, 2026
@dsus4wang
Copy link
Copy Markdown
Author

Hi, the PR involves two different aspects, cron and /list mcp, maybe you mixed the two features, what is the intent of this PR?
Thanks for calling that out. The PR does include two related fixes, and I should make that clearer in the description.

The first part is about cron message authoring. For normal cron jobs, the saved message is replayed into the agent loop as a fresh user-style input when the job fires. Right now, when the model uses the cron tool to create reminders, it sometimes writes the message in third-person form like “notify the user ...”. That is incorrect for this execution model, because the message is later fed back as if it were a direct user request. It should be written in first-person / direct-address form, such as “remind me ...” or “tell me ...”, otherwise the downstream reply becomes awkward.

The second part is the MCP issue we saw in long-running processes, where MCP tools could become unavailable / not be recognized correctly after config reloads. The root cause was that reload was preserving stale MCP runtime state instead of rebuilding tool registrations from the new config. This PR fixes that by rebuilding MCP tools from the reloaded config, removing stale registrations for deleted servers, and exposing /list mcp so the current MCP status can be inspected more easily when debugging those cases.

So the intent of the PR is:

  1. fix incorrect cron reminder message wording generated by the model
  2. fix MCP tool visibility/state issues in long-running instances and add /list mcp as an observability aid

I’ll update the PR description/title to make those two scopes explicit.

@afjcjsbx
Copy link
Copy Markdown
Collaborator

ok clear, it would be better however to split the two functionalities into two separate PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants