Skip to content

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

Closed
zhanggttry wants to merge 2 commits intoopenclaw:mainfrom
zhanggttry:feat/cron-list-agentid-filter
Closed

feat(cron): add agentId filtering to cron list#77188
zhanggttry wants to merge 2 commits intoopenclaw:mainfrom
zhanggttry:feat/cron-list-agentid-filter

Conversation

@zhanggttry
Copy link
Copy Markdown
Contributor

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

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

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.

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

When called from an agent session without explicit agentId, the tool
auto-fills it from the calling agent's session context. When called
from CLI without --agent, all jobs are shown (backward compatible).

Closes openclaw#77118
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: XS labels May 4, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 4, 2026

Codex review: needs changes before merge.

Summary
The PR adds an optional agentId filter to cron.list across the protocol, service, gateway handler, agent cron tool, CLI, and generated Swift protocol models.

Reproducibility: yes. Source inspection shows current main has no agentId field in cron.list, and the PR defect is reproducible from code because cron add/edit normalize stored agent IDs while the new list filter compares the raw requested value.

Next step before merge
The remaining blockers are narrow mechanical repairs suitable for an automated follow-up on the PR branch or a replacement branch.

Security
Cleared: The diff adds optional cron list filtering and generated protocol model fields without changing dependencies, workflows, scripts, package metadata, secrets handling, or execution permissions.

Review findings

  • [P2] Normalize agent IDs before filtering cron jobs — src/cron/service/ops.ts:289-291
  • [P3] Add the required docs and changelog entry — src/cli/cron-cli/register.cron-add.ts:48
Review details

Best possible solution:

Land this as a focused cron feature after normalizing the filter value consistently and adding regression tests plus docs/changelog entries.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main has no agentId field in cron.list, and the PR defect is reproducible from code because cron add/edit normalize stored agent IDs while the new list filter compares the raw requested value.

Is this the best way to solve the issue?

No, not yet. The API shape is reasonable, but the maintainable fix should normalize the requested agent ID before filtering and ship with tests, docs, and changelog coverage.

Full review comments:

  • [P2] Normalize agent IDs before filtering cron jobs — src/cron/service/ops.ts:289-291
    The new filter compares the requested agentId to job.agentId verbatim. Cron creation and edits canonicalize IDs, so openclaw cron add --agent Ops ... stores ops but openclaw cron list --agent Ops would return no jobs; normalize the list filter before comparing and cover that path.
    Confidence: 0.9
  • [P3] Add the required docs and changelog entry — src/cli/cron-cli/register.cron-add.ts:48
    This exposes a user-facing CLI/tool/protocol feature, but the PR changes only source and generated protocol files. Add the required changelog entry plus cron docs for cron list --agent, and include focused regression coverage for the new behavior.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.87

Acceptance criteria:

  • pnpm test src/cron/service.list-page-sort-guards.test.ts src/gateway/protocol/cron-validators.test.ts src/gateway/server.cron.test.ts src/agents/tools/cron-tool.test.ts src/cli/cron-cli.test.ts
  • pnpm exec oxfmt --check --threads=1 src/cron/service/ops.ts src/cron/service/list-page-types.ts src/gateway/protocol/schema/cron.ts src/gateway/server-methods/cron.ts src/agents/tools/cron-tool.ts src/cli/cron-cli/register.cron-add.ts docs/cli/cron.md docs/automation/cron-jobs.md CHANGELOG.md
  • pnpm check:changed

What I checked:

  • Current main cron tool list is unfiltered: Current main sends only includeDisabled from the agent cron tool for the list action, so the linked feature gap is real on main. (src/agents/tools/cron-tool.ts:656, fcb396bf6589)
  • Current main protocol lacks agentId list parameter: CronListParamsSchema accepts paging/query/sort fields but no agentId, matching the linked issue's report. (src/gateway/protocol/schema/cron.ts:282, fcb396bf6589)
  • PR filter compares raw agent IDs: The PR adds an opts.agentId filter in listPage, but the comparison is against job.agentId verbatim rather than the normalized form used when jobs are created or patched. (src/cron/service/ops.ts:289, d50cfbb7ae2f)
  • Stored cron job agent IDs are normalized: Cron job creation stores agentId through normalizeOptionalAgentId, and CLI add sanitizes --agent, so list filtering must normalize the requested filter consistently. (src/cron/service/jobs.ts:591, fcb396bf6589)
  • Cron docs do not cover list filtering: The current cron CLI docs cover cron list and agent retargeting for edit/add, but not a cron list --agent filter; the PR diff also contains no docs, tests, or changelog files. Public docs: docs/cli/cron.md. (docs/cli/cron.md:222, fcb396bf6589)

Likely related people:

  • Peter Steinberger: Local history shows multiple recent cron service and CLI refactors touching the relevant normalization and cron CLI surfaces. (role: cron feature/refactor maintainer; confidence: high; commits: e66c418c4533, b1c30f0ba9b8, e86b38f09d85; files: src/cron/service/ops.ts, src/cron/normalize.ts, src/cli/cron-cli/register.cron-add.ts)
  • Tyler Yust: A prior cron consolidation commit touched the cron service, gateway handler, CLI tests, and cron docs, which overlap the PR's user-facing behavior and documentation needs. (role: adjacent cron delivery/docs maintainer; confidence: medium; commits: 38543d819690; files: src/cron/service/ops.ts, src/gateway/server-methods/cron.ts, src/cli/cron-cli.test.ts)
  • Vincent Koc: Current-main blame in this checkout points the central cron list, cron tool, CLI list, and protocol schema lines to a recent broad commit; the trail is less specific because that commit is not cron-focused. (role: recent current-main maintainer; confidence: low; commits: 8a8a12559df0; files: src/cron/service/ops.ts, src/agents/tools/cron-tool.ts, src/cli/cron-cli/register.cron-add.ts)

Remaining risk / open question:

  • List filtering will silently miss jobs when callers pass non-canonical agent IDs such as different casing or extra invalid characters.
  • The user-facing CLI/tool/protocol change has no regression coverage, docs, or changelog entry in the proposed diff.

Codex review notes: model gpt-5.5, reasoning high; reviewed against fcb396bf6589.

@openclaw-barnacle openclaw-barnacle Bot added the app: macos App: macos label May 4, 2026
@Takhoffman
Copy link
Copy Markdown
Contributor

@clawsweeper automerge

@clawsweeper clawsweeper Bot added the clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge label May 4, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 4, 2026

🦞🔧
ClawSweeper automerge is enabled.

Draft PRs stay fix-only until GitHub marks them ready for review. Pause with /clawsweeper stop.

Automerge progress:

  • 2026-05-04 23:57:30 UTC review queued 7d85812b429f (queued)

@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 5, 2026

ClawSweeper 🐠 reef update

Thanks for the work on this. ClawSweeper did not have permission to update this branch directly, so it opened a narrow replacement PR instead. that's a branch access thing, not a knock on the contribution.

Replacement PR: #77602
Closing this source PR only because source-PR closing was explicitly enabled for this run.
The replacement PR carries the original credit trail forward.

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

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

Labels

agents Agent runtime and tooling app: macos App: macos app: web-ui App: web-ui clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge cli CLI command changes gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: cron list should support agentId filtering in multi-agent setups

2 participants