Skip to content

feat(cron): add get and update actions to cron tool#2977

Open
SutraHsing wants to merge 2 commits into
sipeed:mainfrom
SutraHsing:cron-get-update
Open

feat(cron): add get and update actions to cron tool#2977
SutraHsing wants to merge 2 commits into
sipeed:mainfrom
SutraHsing:cron-get-update

Conversation

@SutraHsing
Copy link
Copy Markdown

@SutraHsing SutraHsing commented May 31, 2026

📝 Description

Add get and update actions to the existing agent-facing cron tool.

This lets agents inspect the full persisted cron job payload before editing, then apply partial updates without recreating the job. The main goal is to prevent rescheduling flows from using remove -> add, which can accidentally drop the original prompt, delivery target, command payload, or formatting instructions.

This PR also updates cron service behavior so schedule/enabled changes recompute NextRunAtMS, while payload-only updates preserve existing run state.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 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: Existing cron schedule changes required recreating jobs in some agent workflows. Recreating a job can lose long prompts and saved payload fields. get exposes the full persisted job, and update preserves omitted fields by default, making the recommended workflow list -> get -> update.

🧪 Test Environment

  • Hardware: Mac
  • OS: macOS
  • Model/Provider: GLM-5.1
  • Channels: Feishu

📸 Evidence (Optional)

Click to view Logs/Screenshots

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

Add GetJob and improved UpdateJob to CronService with proper cloning,
schedule diffing, and next-run recomputation. Expose get/update actions
in the cron tool so agents can inspect and partially update jobs without
losing payloads or needing remove+add cycles. Includes access control
for remote channels and command safety gates.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 31, 2026

CLA assistant check
All committers have signed the CLA.

@afjcjsbx
Copy link
Copy Markdown
Collaborator

afjcjsbx commented May 31, 2026

Hi, The new get/update paths do not perform any authorization checks on the requested job: pkg/tools/cron.go reads any job_id, and pkg/tools/cron.go modifies it without validating or comparing the caller against job.Payload.Channel/To.

Since list continues to globally expose job names and IDs in pkg/tools/cron.go, a remote user could easily enumerate jobs from other chats. They could then perform a get request to exfiltrate complete payloads (including the command) or an update request to alter other users' reminders.

The PR itself adds tests describing the expected authorized behavior in pkg/tools/cron_test.go, and they currently fail on this branch when running:

go test ./pkg/tools -run 'TestCronTool_'

@SutraHsing
Copy link
Copy Markdown
Author

@afjcjsbx Thanks mate. That makes sense. btw, After the fix, I noticed ci lint errors. Is that necessary to fix?

pkg/tools/cron.go:88: 88-132 lines are duplicate of pkg/tools/shell.go:218-262 (dupl)

@afjcjsbx
Copy link
Copy Markdown
Collaborator

yes please 🙏

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants