Repository navigation
Description
cron tool: add per-agent/session isolation for job visibility and mutations
Summary
The cron tool stores agentId and sessionKey on every job (CronJobBase in types-shared.ts), and the cron-tool.ts already populates these fields automatically when a job is created. However, the service layer (cron/service/ops.ts) and gateway handlers (gateway/server-methods/cron.ts) perform no filtering on these fields, meaning:
cron.listreturns all jobs from all agents/sessionscron.remove,cron.update,cron.runoperate on any job by ID, regardless of which agent or session created it
This makes it impossible to safely expose the cron tool to multiple users in a multi-user deployment where each user has their own isolated session (e.g. session.dmScope: "per-channel-peer").
Expected Behavior
When a cron tool call is made from an agent session:
cron.listshould only return jobs whoseagentIdorsessionKeymatches the caller's session context (with an opt-in override for admins to see all).cron.remove/cron.update/cron.runshould verify that the target job'sagentId/sessionKeymatches the caller before allowing the mutation. Attempts to mutate another agent's job should return an authorization error.
Current Behavior
All cron operations are global. Any user with the cron tool available (i.e. senderIsOwner: true) can:
- List every job created by every other user
- Delete or modify jobs they did not create
- Manually trigger jobs belonging to other agents
Context
CronJobBasealready hasagentId?: stringandsessionKey?: stringfieldscron-tool.tsalready auto-populatesagentIdandsessionKeyoncron.addfromopts.agentSessionKey- The gateway handler in
server-methods/cron.tscurrently receives no caller identity — thecontextobject would need to carry the requestingagentId/sessionKeyfor enforcement to be possible - The
CronListPageOptionstype inops.tswould needagentId?: stringandsessionKey?: stringfilter fields
Suggested Fix
- Thread the requesting agent's
sessionKey(oragentId) through the gateway method context into the cron service ops. - Add
agentIdandsessionKeyfilter parameters toCronListPageOptionsandlistPage(). - In
remove(),update(), andrun(), look up the job first and compare itsagentId/sessionKeyagainst the caller before proceeding. - Provide a bypass flag (e.g.
ownerOverride: true) for the primary admin session to retain full visibility and control.
Use Case
Multi-user DingTalk/Telegram/Slack deployments where each user is routed to their own isolated agent session and all users have cron access. Without this fix, enabling cron for all users means every user can see and destroy every other user's scheduled jobs.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
sahilsatralkar commentedon Mar 5, 2026
HI, I am looking into this feature request, will update here with my findings
songchenghao commentedon Mar 6, 2026
Issue: Cron isolated jobs don't execute in sandbox despite
sandbox.mode="all"Description
When a cron job is configured with
sessionTarget: "isolated"and the agent hassandbox.mode: "all", the job still executes in the Gateway process instead of the sandbox container.Current Behavior
Expected Behavior
Cron isolated jobs should respect
sandbox.mode="all"configuration and execute in the sandbox container.Configuration
Reproduction
sandbox.mode: "all"sessionTarget: "isolated"Test Case
Job with message:
hostname && whoami && pip3 listRoot Cause (from code review)
Based on source code analysis:
src/cron/isolated-agent/run.tscallsrunEmbeddedPiAgent()which should support sandboxsrc/agents/sandbox/runtime-status.tsshouldSandboxSession()should return true formode="all", but seems bypassed in cron execution pathWorkaround
Install required dependencies in the Gateway container instead of relying on sandbox isolation.
Environment
This impacts workflows where cron jobs need isolated environments with specific dependencies that are only available in sandbox containers.
clawsweeper commentedon Apr 26, 2026
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.
Close as duplicate/superseded: the remaining cron ownership work is already covered by the older canonical tracker at #26370, with the narrower all-runs name leak tracked at #49175; current main only implements the list-side agent filter, not the requested mutation/session authorization.
So I’m closing this here and keeping the remaining discussion on the canonical linked item.
Review details
Best possible solution:
Consolidate follow-up under #26370 for the full trusted cron ownership model, while keeping #49175 for the run-history name leak until the shared fix covers it.
Do we have a high-confidence way to reproduce the issue?
Yes, source-level reproduction is high confidence: create jobs with different agentId/sessionKey values, then update/remove/run another job by id or request all-scope run history; current main lacks caller ownership checks on those paths. I did not run a live repro because this read-only review environment has no pnpm available.
Is this the best way to solve the issue?
Yes, duplicate closure is the best cleanup path for this item because the remaining work is already tracked by the older, richer production-context issue and a narrower run-history leak issue. A new fix should be designed there rather than splitting the same access-control decision across parallel trackers.
Security review:
Security review needs attention: The underlying issue remains security-sensitive because current main still lacks caller ownership checks for cron mutations and all-scope run-history naming.
src/cron/service/ops.ts:368update, remove, run, and enqueueRun still operate by job id without a trusted caller scope or agentId/sessionKey comparison, so the remaining fix needs access-control review under the canonical tracker.
Confidence: 0.92
src/gateway/server-methods/cron.ts:506The cron.runs all-scope handler builds its job-name map from the unfiltered cron list, so job names can still cross session boundaries until the run-history tracker is fixed.
Confidence: 0.9
What I checked:
src/cron/types-shared.ts:4, 51dc4a20be70)src/cron/service/ops.ts:292, 51dc4a20be70)src/gateway/server-methods/cron.ts:204, 51dc4a20be70)src/cron/service-contract.ts:27, 51dc4a20be70)src/gateway/server-methods/cron.ts:506, 51dc4a20be70)Likely related people:
src/cron/service/ops.ts,src/gateway/server-methods/cron.ts,src/gateway/protocol/schema/cron.ts)src/gateway/server-methods/cron.ts,src/gateway/protocol/schema/cron.ts,src/cron/service/ops.ts)src/agents/tools/cron-tool.ts,src/cron/service/ops.ts,src/gateway/server-methods/cron.ts)src/cron/service/ops.ts,src/gateway/server-methods/cron.ts,src/agents/tools/cron-tool.ts)Codex review notes: model gpt-5.5, reasoning high; reviewed against 51dc4a20be70.