Skip to content

perf(agents): ship one automations job schema for add and update - #121645

Merged
steipete merged 1 commit into
mainfrom
claude/pr-land-fix-70f009
Aug 10, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/pr-land-fix-70f009

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The automations tool's JSON Schema was the single largest tool-schema item on the default tool path: 13,016 chars (~3.25k tokens) in every prompt, 88% of it two hand-maintained near-duplicate parameters — job (5,533 chars, add only) and patch (5,922 chars, update only). Both shipped on every turn even though each applies to one of ten actions. Fixes #121606.

Why This Change Was Made

Issue #121606 listed three options. $defs/$ref sharing (option 1) is blocked by the llama.cpp GBNF projection guard (findLlamacppGbnfSchemaViolations in cron-tool.schema.test.ts) and OpenAPI-3.0-subset providers. This PR implements option 2: one shared object schema for both actions, matching the repo's one-canonical-flow preference.

  • src/agents/tools/cron-tool-schema.ts: createCronPatchObjectSchema() and the entire nullableClears parameterization are deleted. One createCronJobObjectSchema() (nullable-clear everywhere the patch was, plus the add-only declarationKey/owner fields) serves add and update. The object's description states the per-action semantics.
  • update now reads the job parameter; the patch parameter is removed cleanly (root AGENTS.md: no hidden compat for model-facing params). The tool description documents update jobId job (partial: only supplied fields change; null clears).
  • The add path strips null-valued fields (stripCronCreateNullClears) before the strict gateway cron.add contract, which rejects the nulls cron.update accepts. A null clear on create is a no-op. Top-level agentId/sessionKey nulls are preserved: CronAddParamsSchema accepts them and a null sessionKey intentionally suppresses default creator-session binding (cron-tool.ts).
  • The gateway protocol (CronAddParamsSchema/CronUpdateParamsSchema) is untouched; this is a model-facing tool-boundary change only.

User Impact

Every turn of every agent on the default tool path gets ~5.2k fewer schema chars (~1.3k tokens, −40% of the automations schema): 13,016 → 7,864 chars. The Codex dynamic-tools catalog snapshot dropped from 65,134 to 51,863 chars (~3.3k rough tokens including serialization overhead). Accepted inputs are unchanged for add; update calls move their patch object from patch to job, and nulls sent on add (previously schema-invalid) are now tolerated as no-ops instead of failing at the gateway.

Note: this branch briefly carried a config/env-var-count-budget.txt 507→503 ratchet fix for then-red main; #121644 landed the identical change first and the commit auto-dropped on rebase.

Evidence

  • Baseline vs. after (createCronToolSchema() serialized): 13,016 chars / patch 5,922 + job 5,533 → 7,864 chars / job 6,312, no patch. ~1,290 tokens saved per prompt.
  • node scripts/run-vitest.mjs src/agents/tools/cron-tool.test.ts src/agents/tools/cron-tool.flat-params.test.ts src/agents/tools/cron-tool.schema.test.ts — 245 tests green, including the llama.cpp GBNF projection guard, OpenAPI-3.0 provider projections (Gemini/jjcc), and a new regression test proving add strips null clears before cron.add while preserving the sessionKey: null binding-suppression contract.
  • node scripts/run-vitest.mjs src/agents/tools/cron-tool-creator-cap.test.ts src/cron/normalize.test.ts src/gateway/server-methods — green.
  • pnpm prompt:snapshots:gen + pnpm prompt:snapshots:check — snapshots current.
  • Production LOC net −59 (schema −87, canonicalize +27, tool +1); tests net −35.

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 10, 2026 15:43
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 10, 2026
@steipete steipete closed this Aug 10, 2026
@steipete steipete reopened this Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 10, 2026, 3:49 PM ET / 19:49 UTC.

ClawSweeper review

What this changes

The PR replaces separate Automations add and update job schemas with one nullable job object, then refreshes the affected prompt snapshots.

Merge readiness

⛔ Blocked by patch quality or review findings - 7 items remain

Two source-proven scheduler-contract defects block merge: the shared schema advertises an update field that Gateway rejects, and add-time null cleanup can leave an invalid empty delivery object.

Priority: P2
Reviewed head: 1c4f3f20927e5461e389c11fe1aff87e377120a6

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The context-saving refactor is focused, but two source-proven contract defects leave it unready to merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported focused tests remain supplemental validation.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported focused tests remain supplemental validation.
Evidence reviewed 4 items Shared owner field conflicts with update contract: The shared job schema exposes owner while describing update as a partial patch; the closed Gateway patch schema excludes owner.
Create null cleanup leaves invalid delivery: The new recursive stripper removes nested nulls but retains delivery:{}, which create normalization retains even though Gateway accepts only mode-specific delivery shapes.
Prior finding remains unresolved: The prior review requested add-only guidance for owner. declarationKey now has it, but owner remains unqualified in the shared schema.
Findings 2 actionable findings [P2] Mark owner as add-only in the shared schema
[P2] Prune empty containers after stripping create nulls
Security None None.

How this fits together

The Automations tool is injected into agent context and turns model scheduler requests into Gateway cron add or update calls. Gateway preserves distinct strict contracts for complete job creation and partial job updates.

flowchart LR
  A[Agent prompt] --> B[Automations schema]
  B --> C[Model scheduler request]
  C --> D[Tool normalization]
  D --> E{Add or update}
  E --> F[Gateway cron add]
  E --> G[Gateway cron update]
  F --> H[Scheduled job]
  G --> H
Loading

Before merge

  • Mark owner as add-only in the shared schema (P2) - owner is visible in the sole job schema, whose changed description says supplied update fields are patched. The update path forwards it to cron.update, but the closed Gateway patch schema excludes it. Give owner the same add-only guidance as declarationKey and cover the boundary.
  • Prune empty containers after stripping create nulls (P2) - Removing the only nullable delivery field leaves delivery: {}. Create normalization preserves that object, but cron.add accepts only mode-specific delivery objects, so a shared-schema create request fails instead of becoming a no-op. Omit empty optional containers and add a tool-boundary regression.
  • Resolve merge risk (P1) - The model-facing shared schema can cause update calls with owner to fail strict Gateway validation.
  • Resolve merge risk (P1) - Schema-valid add requests containing only nullable delivery clears can fail instead of becoming no-ops.
  • Complete next step (P2) - This maintainer-owned protected PR needs its two narrow fixes applied and revalidated before merge.
  • Improve patch quality - Mark owner as add-only and prevent it from reaching update.
  • Improve patch quality - Prune empty create containers after nullable-clear stripping and add a gateway-boundary regression.

Findings

  • [P2] Mark owner as add-only in the shared schema — src/agents/tools/cron-tool-schema.ts:285-287
  • [P2] Prune empty containers after stripping create nulls — src/agents/tools/cron-tool-canonicalize.ts:320-326
Agent review details

Security

None.

PR surface

Source -60, Tests -374. Total -434 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 3 110 170 -60
Tests 7 232 606 -374
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 342 776 -434

Review metrics

Metric Value Why it matters
Production vs test LOC production +110/-170 (net -60); tests and snapshots +232/-606 (net -374) The refactor deletes substantial duplicated schema, while the remaining production additions own null normalization.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/agents/tools/cron-tool-schema.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #121606
Summary: This PR is the active candidate implementation of the duplicated scheduler-schema cost issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Repair the shared scheduler boundary (recommended)
    Mark owner add-only and prune empty add-time containers, with regressions for update owner and delivery-only null clears.
  2. Pause the consolidation
    Retain separate schemas if one shared schema cannot accurately express create-only fields and create no-op semantics.

Technical review

Best possible solution:

Keep the one-schema design, but mark every create-only field explicitly and omit empty optional containers after add-time null removal.

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

Yes, by source: update job.owner reaches the closed Gateway patch schema, and add delivery.completionDestination:null is stripped to delivery:{} before create validation.

Is this the best way to solve the issue?

No: consolidation is the right direction, but it must preserve action-specific field limits and no-op clear semantics before replacing the separate schemas.

Full review comments:

  • [P2] Mark owner as add-only in the shared schema — src/agents/tools/cron-tool-schema.ts:285-287
    owner is visible in the sole job schema, whose changed description says supplied update fields are patched. The update path forwards it to cron.update, but the closed Gateway patch schema excludes it. Give owner the same add-only guidance as declarationKey and cover the boundary.
    Confidence: 0.99
  • [P2] Prune empty containers after stripping create nulls — src/agents/tools/cron-tool-canonicalize.ts:320-326
    Removing the only nullable delivery field leaves delivery: {}. Create normalization preserves that object, but cron.add accepts only mode-specific delivery objects, so a shared-schema create request fails instead of becoming a no-op. Omit empty optional containers and add a tool-boundary regression.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8a5978154f69.

Labels

Label justifications:

  • P2: This bounded default-path scheduler-tool regression causes rejected requests but is not an emergency availability or data-loss incident.
  • merge-risk: 🚨 compatibility: The shared model schema now diverges from Gateway's distinct create and partial-update contracts.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported focused tests remain supplemental validation.

Evidence

What I checked:

Likely related people:

  • steipete: The current PR and the blamed scheduler schema/protocol boundary are attributed to Peter Steinberger. (role: feature owner and recent area contributor; confidence: high; commits: 1c4f3f20927e, 3b3c540896ab; files: src/agents/tools/cron-tool-schema.ts, packages/gateway-protocol/src/schema/cron.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-10T15:49:54.367Z sha d9a147ecfa1d66bf18bc58a2f09cad96d571bbf1 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-10T15:55:58.398Z sha d9a147ecfa1d66bf18bc58a2f09cad96d571bbf1 :: found issues before merge. :: [P2] Mark owner as add-only in the shared job schema
  • reviewed 2026-08-10T17:02:18.506Z sha d9a147ecfa1d66bf18bc58a2f09cad96d571bbf1 :: needs changes before merge. :: [P2] Mark owner as add-only in the shared job schema
  • reviewed 2026-08-10T18:59:32.569Z sha f0e0d291a3d47d5364482e51e96088632d9ee20a :: found issues before merge. :: [P2] Mark owner as add-only in the shared job schema

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 10, 2026
@steipete
steipete force-pushed the claude/pr-land-fix-70f009 branch 2 times, most recently from f0e0d29 to d0aedfb Compare August 10, 2026 19:24
The automations tool shipped two near-duplicate ~1.4k-token object schemas
(job for add, patch for update) in every prompt on the default tool path —
13,016 chars of tool schema, 88% of it the duplicated pair. One nullable
object schema now serves both actions (7,864 chars, ~1.3k tokens saved per
prompt): update reads the job parameter, and the add path strips null
clears before the strict gateway cron.add contract while preserving the
agentId/sessionKey nulls that cron.add accepts.

Fixes #121606
@steipete
steipete force-pushed the claude/pr-land-fix-70f009 branch from d0aedfb to 1c4f3f2 Compare August 10, 2026 19:44
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 10, 2026
@steipete
steipete merged commit 9edc531 into main Aug 10, 2026
125 of 126 checks passed
@steipete
steipete deleted the claude/pr-land-fix-70f009 branch August 10, 2026 20:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 11, 2026
…nclaw#121645)

The automations tool shipped two near-duplicate ~1.4k-token object schemas
(job for add, patch for update) in every prompt on the default tool path —
13,016 chars of tool schema, 88% of it the duplicated pair. One nullable
object schema now serves both actions (7,864 chars, ~1.3k tokens saved per
prompt): update reads the job parameter, and the add path strips null
clears before the strict gateway cron.add contract while preserving the
agentId/sessionKey nulls that cron.add accepts.

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

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(agents): automations tool schema is ~3.2k tokens of every prompt; job/patch are near-duplicates

1 participant