refactor(cron): remove deliver and type params, unify agent execution path#2147
refactor(cron): remove deliver and type params, unify agent execution path#2147yinwm wants to merge 1 commit intosipeed:mainfrom
Conversation
… path The agent path now publishes to outbound bus directly (since sipeed#2100), making the deliver=true direct-to-bus shortcut and the directive type prompt wrapping redundant. All cron jobs now uniformly route through the agent. This is an intentional behavior change: old jobs with deliver=true will execute through the agent instead of bypassing it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Removes the legacy deliver and type parameters from the cron system and routes non-command cron jobs through the agent execution path, aligning cron behavior with the post-#2100 outbound publishing flow.
Changes:
- Remove
deliver/typefields from cron payloads and tool schema; remove directive/direct-delivery execution branches. - Update cron job creation APIs/signatures and CLI to drop
deliver. - Delete related tests that asserted deliver/type behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tools/cron.go | Removes deliver/type parameters and simplifies job execution to always call the agent for non-command jobs. |
| pkg/tools/cron_test.go | Removes tests for deliver/type/directive behaviors; retains agent-response publishing coverage. |
| pkg/cron/service.go | Removes persisted payload fields and updates AddJob signature accordingly. |
| pkg/cron/service_test.go | Updates tests to match new AddJob signature. |
| cmd/picoclaw/internal/cron/add.go | Removes --deliver flag and updates job creation call. |
| cmd/picoclaw/internal/cron/add_test.go | Updates CLI flag assertions to match removed --deliver. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Call agent with the job message | ||
| response, err := t.executor.ProcessDirectWithChannel( | ||
| ctx, | ||
| prompt, | ||
| job.Payload.Message, | ||
| sessionKey, | ||
| channel, | ||
| chatID, |
There was a problem hiding this comment.
Cron execution is invoked with context.Background() (see gateway setup), so this agent call (and the subsequent outbound publish via PublishResponseIfNeeded) currently has no deadline. Since MessageBus.PublishOutbound can block when buffers fill, please consider wrapping cron job execution/publish in a timeout context to prevent the cron loop from getting stuck behind a slow agent run or blocked outbound consumer.
| "command": map[string]any{ | ||
| "type": "string", | ||
| "description": "Optional: Shell command to execute directly (e.g., 'df -h'). If set, the agent will run this command and report output instead of just showing the message. 'deliver' will be forced to false for commands.", | ||
| "description": "Optional: Shell command to execute directly (e.g., 'df -h'). If set, the agent will run this command and report output instead of just showing the message.", |
There was a problem hiding this comment.
The command parameter description says “the agent will run this command”, but ExecuteJob runs scheduled commands by calling t.execTool.Execute(...) directly and then publishing to the outbound bus (no agent loop involved). Please update the schema description to match actual behavior (e.g., “Cron executes the command via the exec tool and publishes the output”).
| "description": "Optional: Shell command to execute directly (e.g., 'df -h'). If set, the agent will run this command and report output instead of just showing the message.", | |
| "description": "Optional: Shell command to execute directly (e.g., 'df -h'). If set, Cron executes this command via the exec tool and publishes the output instead of just showing the message.", |
Summary
deliver(bool) andtype(message/directive) parameters from cron systemdeliver=truedirect-to-bus shortcut is now redundant since fix(cron): publish agent response to outbound bus for cron-triggered jobs #2100 unified agent responses to publish to outbound busBreaking change
Old persisted jobs with
deliver: trueortype: "directive"will silently ignore these fields (Go json.Unmarshal behavior). All jobs now execute through the agent instead of bypassing it. This is intentional.Test plan
make testpasses (all packages ok)🤖 Generated with Claude Code