openclaw - ✅(Solved) Fix Feature request: cron list should support agentId filtering in multi-agent setups [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77118Fetched 2026-05-05 05:51:56
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
2
Timeline (top)
cross-referenced ×3referenced ×3commented ×1

Fix Action

Workaround

Currently mitigating by adding instructions to each agent's HEARTBEAT.md:

"调用 cron list 时,只关注 agentId=<own-agent> 的任务。其他 agentId 的任务与本 agent 无关,必须忽略。"

This works but relies on LLM compliance and wastes context window on irrelevant jobs.

PR fix notes

PR #77188: feat(cron): add agentId filtering to cron list

Description (problem / solution / changelog)

Summary

Adds optional agentId parameter to cron list action, allowing agents to filter cron jobs by their own agentId. This reduces noise in multi-agent setups where each agent sees all jobs across all agents.

Closes #77118

Changes

  • Protocol schema: add optional agentId to CronListParamsSchema
  • Service types: add agentId to CronListPageOptions
  • Service ops: filter by agentId when provided in listPage()
  • Gateway handler: pass through agentId param
  • Agent tool: auto-fill agentId from session context (mirrors existing behavior in cron add)
  • CLI: add --agent <id> option to openclaw cron list

Behavior

CalleragentId behavior
Agent tool (no explicit agentId)Auto-filled from calling agent session
Agent tool (explicit agentId)Uses the provided value
CLI without --agentShows all jobs (backward compatible)
CLI with --agent my-agentFilters to that agent

Changed files

  • apps/macos/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • src/agents/tools/cron-tool.ts (modified, +12/-2)
  • src/cli/cron-cli/register.cron-add.ts (modified, +7/-2)
  • src/cron/service/list-page-types.ts (modified, +1/-0)
  • src/cron/service/ops.ts (modified, +3/-0)
  • src/gateway/protocol/schema/cron.ts (modified, +1/-0)
  • src/gateway/server-methods/cron.ts (modified, +2/-0)

PR #77191: feat(cron): add optional agentId filter to cron.list

Description (problem / solution / changelog)

Summary

Adds an additive optional agentId filter to cron.list so multi-agent installs can scope cron job listings to a single agent's jobs. Omitting agentId preserves the historical "all jobs across all agents" result, so every existing client keeps working.

This delivers the gateway-side foundation only. Tool-layer auto-fill from session context and a --agent CLI flag are sensible follow-ups but stay out of this PR to keep the change reviewable as one tight contract evolution.

Why

From the issue: in a 7-agent install with ~54 cron jobs, every agent's cron list returned all 54 jobs. Heartbeat prompts wasted tokens parsing irrelevant jobs, agents could see (and potentially modify via update/add) other agents' jobs, and prompt confusion led to incorrect status reports. The reporter mitigated locally by adding inline HEARTBEAT.md instructions to ignore other agents' jobs — a workaround pointing at a missing server-side capability.

Changes

  • src/cron/service/list-page-types.ts — Add agentId?: string to CronListPageOptions with a docstring linking the issue.
  • src/cron/service/ops.ts — In listPage, normalize the input (treat empty/whitespace as omitted), compute agentIdFilter once, and apply it inside the existing source.filter(...) predicate so it composes with enabledFilter and query.
  • src/gateway/protocol/schema/cron.ts — Add agentId: Type.Optional(Type.String()) to CronListParamsSchema. Schema is additionalProperties: false, so this is the canonical place for the new field.
  • src/gateway/server-methods/cron.ts — Thread agentId through the cron.list handler into context.cron.listPage(...).
  • src/cron/service.list-page-agent-filter.test.ts — 5 new regression tests:
    • matches only the target agent's jobs
    • omitted agentId returns every job (backward compatible)
    • empty/whitespace agentId is treated as omitted
    • no-match returns an empty page
    • composes with the existing query filter
  • CHANGELOG.md — Unreleased > Changes entry credited to me.

Boundary considerations

Per src/gateway/protocol/CLAUDE.md: schema changes are protocol changes, prefer additive evolution. This is purely additive — no existing field changes shape, no required field added, schema stays additionalProperties: false. Existing clients that omit agentId are unaffected.

Test plan

  • pnpm test src/cron/service.list-page-agent-filter.test.ts src/cron/service.list-page-sort-guards.test.ts — 7/7 pass (5 new + 2 existing)
  • pnpm test src/gateway/protocol/cron-validators.test.ts — 12/12 pass
  • pnpm exec oxfmt --check on touched files — clean

Fixes #77118.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • apps/macos/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • src/cron/service.list-page-agent-filter.test.ts (added, +135/-0)
  • src/cron/service.test-harness.ts (modified, +2/-0)
  • src/cron/service/list-page-types.ts (modified, +7/-0)
  • src/cron/service/ops.ts (modified, +20/-0)
  • src/gateway/protocol/schema/cron.ts (modified, +6/-0)
  • src/gateway/server-methods/cron.ts (modified, +2/-0)

PR #77602: feat(cron): add agentId filtering to cron list

Description (problem / solution / changelog)

Summary

  • Repair #77188 in place by normalizing requested agent IDs before cron list filtering.
  • Keep CLI cron list backward compatible when --agent is omitted, while allowing explicit filtering.
  • Document the new cron list agent filter and add the required changelog entry.

Closes #77118. This carries forward the implementation and credit from @zhanggttry in https://github.com/openclaw/openclaw/pull/77188.

Verification

  • pnpm test src/cron/service.list-page-sort-guards.test.ts src/gateway/protocol/cron-validators.test.ts
  • pnpm check:changed

ClawSweeper 🐠 replacement reef notes:

  • Cluster: automerge-openclaw-openclaw-77188
  • Source PRs: https://github.com/openclaw/openclaw/pull/77188
  • Credit: Preserve contributor credit for @zhanggttry from source PR https://github.com/openclaw/openclaw/pull/77188.; Issue #77118 by @nicky-openclaw is the motivating report; keep the PR body linked with Closes #77118.; If adding a user-facing CHANGELOG.md entry, use allowed human attribution such as Thanks @zhanggttry.
  • Validation: pnpm test src/cron/service.list-page-sort-guards.test.ts src/gateway/protocol/cron-validators.test.ts; pnpm check:changed
  • Repair fallback: GitHub rejected the repair branch push because it updates workflow files and the ClawSweeper app token does not have workflows permission

fish notes: model gpt-5.5, reasoning high; reviewed against dab0e0aad9ba.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • apps/macos/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • docs/cli/cron.md (modified, +3/-0)
  • src/agents/tools/cron-tool.test.ts (modified, +28/-0)
  • src/agents/tools/cron-tool.ts (modified, +12/-2)
  • src/cli/cron-cli.test.ts (modified, +14/-0)
  • src/cli/cron-cli/register.cron-add.ts (modified, +8/-2)
  • src/cron/service.list-page-sort-guards.test.ts (modified, +52/-0)
  • src/cron/service/list-page-types.ts (modified, +1/-0)
  • src/cron/service/ops.ts (modified, +17/-0)
  • src/gateway/protocol/cron-validators.test.ts (modified, +2/-0)
  • src/gateway/protocol/schema/cron.ts (modified, +1/-0)
  • src/gateway/server-methods/cron.ts (modified, +2/-0)

Code Example

case "list": return jsonResult(await callGateway("cron.list", gatewayOpts, { includeDisabled: Boolean(params.includeDisabled) }));

---

const page = await context.cron.listPage({ includeDisabled, limit, offset, query, enabled, sortBy, sortDir });

---

openclaw cron list --help
# Options: --all, --expect-final, --json, --timeout, --token, --url
# No --agent filter
RAW_BUFFERClick to expand / collapse

Problem

In a multi-agent setup, the cron tool's list action returns all jobs from every agent with no filtering by agentId. This means each agent sees the full cron job catalog (e.g., 50+ jobs across 7 agents), creating confusion and risk of cross-agent interference.

Current behavior

When any agent calls cron list (tool or CLI), the result is unfiltered:

Tool layer (openclaw-tools-BDF6gNXk.js):

case "list": return jsonResult(await callGateway("cron.list", gatewayOpts, { includeDisabled: Boolean(params.includeDisabled) }));

Server layer (server-methods-BDdu1Gof.js):

const page = await context.cron.listPage({ includeDisabled, limit, offset, query, enabled, sortBy, sortDir });

Neither layer passes or accepts an agentId parameter for filtering.

CLI:

openclaw cron list --help
# Options: --all, --expect-final, --json, --timeout, --token, --url
# No --agent filter

Impact

  • Noise: Each agent sees 50+ jobs when only ~8 belong to it. Heartbeat/self-review prompts waste tokens parsing irrelevant jobs.
  • Risk of accidental modification: An agent could modify/delete another agent's cron jobs (the remove action has cronSelfRemoveOnlyJobId protection for cron-triggered contexts, but update and add have no such guard).
  • Prompt confusion: Agents receiving their heartbeat check see cross-agent jobs and may report incorrect status.

Environment

  • OpenClaw 2026.5.2
  • 7 agents (main + 6 sub-agents), ~54 cron jobs total
  • Feishu channel

Suggested fix

  1. Add optional agentId parameter to cron list tool action and CLI (--agent <id>)
  2. Tool layer auto-fills agentId from the calling agent's session context (like cron add already does for new jobs)
  3. Server-side listPage filters by agentId when provided
  4. Default behavior: when called from an agent session, filter to that agent's jobs; when called from CLI without --agent, show all (backward compatible)

Workaround

Currently mitigating by adding instructions to each agent's HEARTBEAT.md:

"调用 cron list 时,只关注 agentId=<own-agent> 的任务。其他 agentId 的任务与本 agent 无关,必须忽略。"

This works but relies on LLM compliance and wastes context window on irrelevant jobs.

Related

  • hooks.allowedAgentIds exists for hook routing but not for cron list filtering
  • cron add correctly auto-sets agentId from the calling session (confirmed in source)
  • The assertCronSelfRemoveScope limits remove in cron-triggered contexts but list/update remain unrestricted

extent analysis

TL;DR

Add an optional agentId parameter to the cron list tool action and CLI to filter jobs by agent.

Guidance

  • Modify the cron list tool action to accept an agentId parameter and pass it to the server layer for filtering.
  • Update the server layer to filter cron jobs by agentId when the parameter is provided.
  • Add a --agent option to the CLI to allow users to specify the agent ID for filtering.
  • Consider adding a default behavior to filter jobs by the calling agent's ID when no agentId is provided.

Example

case "list": 
  const agentId = params.agentId || context.agentId;
  return jsonResult(await callGateway("cron.list", gatewayOpts, { 
    includeDisabled: Boolean(params.includeDisabled), 
    agentId 
  }));

Notes

The current workaround relies on manual instruction and may not be foolproof. Implementing the suggested fix will provide a more robust solution. The hooks.allowedAgentIds and cron add features can serve as references for the implementation.

Recommendation

Apply the workaround by adding the agentId parameter to the cron list tool action and CLI, as it provides a more targeted and efficient solution to the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING