Skip to content

fix(cron-tool): use generic object schema for job/patch to fix Claude via Antigravity#280

Merged
thewilloftheshadow merged 1 commit intoopenclaw:mainfrom
mukhtharcm:fix/cron-tool-schema-antigravity
Jan 6, 2026
Merged

fix(cron-tool): use generic object schema for job/patch to fix Claude via Antigravity#280
thewilloftheshadow merged 1 commit intoopenclaw:mainfrom
mukhtharcm:fix/cron-tool-schema-antigravity

Conversation

@mukhtharcm
Copy link
Copy Markdown
Member

Summary

Fixes a critical bug where the cron tool fails when using Claude models via Google Cloud Code Assist (Antigravity) with:

tools.9.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12

This is a partial revert of #256 - keeps the valuable normalization logic (normalizeCronJobCreate/normalizeCronJobPatch) but reverts the schema change that broke Antigravity+Claude.

Problem

PR #256 changed the cron tool schema from:

job: Type.Object({}, { additionalProperties: true })

to:

job: CronAddParamsSchema

This broke Claude via Antigravity because of a complex interaction between TypeBox, pi-ai schema sanitization, and Claude's JSON Schema validation.

Root Cause Analysis

1. CronAddParamsSchema contains nested Type.Union

// In gateway/protocol/schema.ts
export const CronScheduleSchema = Type.Union([
  Type.Object({ kind: Type.Literal("at"), atMs: Type.Integer() }),
  Type.Object({ kind: Type.Literal("every"), everyMs: Type.Integer() }),
  Type.Object({ kind: Type.Literal("cron"), expr: NonEmptyString }),
]);

export const CronPayloadSchema = Type.Union([
  Type.Object({ kind: Type.Literal("systemEvent"), text: NonEmptyString }),
  Type.Object({ kind: Type.Literal("agentTurn"), message: NonEmptyString, ... }),
]);

2. TypeBox compiles Type.Union to JSON Schema anyOf

{
  "job": {
    "properties": {
      "schedule": {
        "anyOf": [
          { "type": "object", "properties": { "kind": { "const": "at" }, "atMs": { "type": "integer" } } },
          { "type": "object", "properties": { "kind": { "const": "every" }, "everyMs": { "type": "integer" } } },
          { "type": "object", "properties": { "kind": { "const": "cron" }, "expr": { "type": "string" } } }
        ]
      }
    }
  }
}

3. pi-ai's sanitizeSchemaForGoogle() strips anyOf

The schema sanitizer removes unsupported JSON Schema keywords for Google/Gemini APIs:

const unsupportedKeywords = [
  'patternProperties', 'const', 'anyOf', 'oneOf', 'allOf', 'not',
  // ... more
];

After sanitization, nested anyOf properties become empty objects:

{
  "job": {
    "properties": {
      "schedule": {},
      "payload": {},
      "sessionTarget": {},
      "wakeMode": {}
    }
  }
}

4. Claude rejects empty {} schemas

Claude requires valid JSON Schema 2020-12 with explicit type fields. An empty schema {} has no type, which Claude rejects:

tools.9.custom.input_schema: JSON schema is invalid.
It must match JSON Schema draft 2020-12

Why This Wasn't Caught

  1. Provider-specific bug: Only affects Claude via Antigravity, not direct Claude API or Gemini
  2. Recent change: PR Cron: normalize cron.add inputs + align channels #256 was merged Jan 5, 2026
  3. Complex interaction: Requires understanding TypeBox → JSON Schema → sanitization → Claude validation chain
  4. Gateway still worked: The gateway has its own validateCronAddParams() that works fine

Solution

Revert job/patch schemas to Type.Object({}, { additionalProperties: true }):

// Before (broken)
job: CronAddParamsSchema,
patch: CronJobPatchSchema,

// After (fixed)
job: Type.Object({}, { additionalProperties: true }),
patch: Type.Object({}, { additionalProperties: true }),

This produces valid JSON Schema:

{ "job": { "type": "object", "additionalProperties": true } }

Why This Is Safe

  1. Runtime validation preserved: normalizeCronJobCreate() and normalizeCronJobPatch() still clean up AI inputs (this is the valuable part of Cron: normalize cron.add inputs + align channels #256)

  2. Gateway validation preserved: validateCronAddParams() provides clear error messages for invalid job structures

  3. AI still works: Claude can infer the job structure from the tool description and context. The lack of explicit schema doesn't prevent it from creating valid jobs.

  4. Matches working version: This is exactly what was running before Cron: normalize cron.add inputs + align channels #256 and worked fine.

Testing

  • ✅ Tested with claude-opus-4-5-thinking via Google Antigravity
  • ✅ Schema error no longer occurs
  • ✅ Cron job creation works correctly
  • ✅ Build passes

Future Considerations

The proper fix would be to enhance pi-ai's sanitizeSchemaForGoogle() to handle anyOf more gracefully:

  • Merge anyOf variants into a single object with optional properties
  • Or convert anyOf of literals to enum
  • Or add a type field when stripping anyOf leaves an empty schema

This would allow using rich schemas while maintaining Claude compatibility. Filed as a consideration for upstream.

Related

… via Antigravity

## Problem

When using Claude models via Google Cloud Code Assist (Antigravity), the cron
tool fails with:

  tools.9.custom.input_schema: JSON schema is invalid. It must match JSON
  Schema draft 2020-12

## Root Cause Analysis

1. **CronAddParamsSchema contains nested Type.Union**
   - schedule: Type.Union([at, every, cron])
   - payload: Type.Union([systemEvent, agentTurn])
   - sessionTarget: Type.Union([main, isolated])
   - wakeMode: Type.Union([now, next-heartbeat])

2. **TypeBox compiles Type.Union to JSON Schema anyOf**
   ```json
   {
     "schedule": {
       "anyOf": [
         { "type": "object", "properties": { "kind": { "const": "at" }, ... } },
         { "type": "object", "properties": { "kind": { "const": "every" }, ... } },
         ...
       ]
     }
   }
   ```

3. **pi-ai sanitizeSchemaForGoogle() strips anyOf**
   The sanitizer removes unsupported JSON Schema keywords for Google APIs,
   including anyOf, oneOf, allOf, const. After sanitization:
   ```json
   { "schedule": {} }
   ```

4. **Claude rejects empty {} schemas**
   Claude requires valid JSON Schema 2020-12 with explicit types. An empty
   schema {} has no type field, which Claude rejects as invalid.

## Why This Worked Before

Commit a322075 (Jan 5) used Type.Object({}, { additionalProperties: true })
for job/patch, which produces { "type": "object" } - valid for Claude.

Commit 67e1452 (PR openclaw#256, Jan 5) changed this to CronAddParamsSchema to
provide better schema hints to the AI. This broke Antigravity+Claude.

## Solution

Revert job/patch schemas to Type.Object({}, { additionalProperties: true }).

This is safe because:
- Runtime validation via normalizeCronJobCreate/normalizeCronJobPatch (kept)
- Gateway validates via validateCronAddParams with clear error messages
- The AI can still create valid job objects from the tool description

## Testing

- Tested with Claude opus-4-5-thinking via Antigravity
- Schema error no longer occurs
- Cron job creation still works correctly

Partial revert of 67e1452 - keeps normalization logic, reverts schema change.
@mukhtharcm mukhtharcm force-pushed the fix/cron-tool-schema-antigravity branch 2 times, most recently from a531e88 to 9012c22 Compare January 6, 2026 07:51
@thewilloftheshadow thewilloftheshadow merged commit 42d1c24 into openclaw:main Jan 6, 2026
26 checks passed
dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 9, 2026
* Add execution layer runtime parity gap analysis

Comprehensive analysis of Pi Runtime vs Claude Agent SDK feature
gaps in the unified execution layer, with 20 prioritized next steps.

https://claude.ai/code/session_017oEzmayzdirGAKmSw2ryQZ

* Meridia: wire multi-factor scoring into capture hook

* merge/minor fixes for ui/*

* Meridia: add per-capture graph fanout queue with retries

* Meridia: enforce sanitization before persistence and fanout

* Meridia: complete Tier2 vector probing and Postgres vector support

---------

Co-authored-by: Claude <[email protected]>
dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 9, 2026
* feat: tool journal/diagnostics

* feat: journal fixes

* feat(ui): add error boundary component with retry & friendly messages

- New error-boundary.ts component with renderError/renderErrorIf helpers
- Custom element <error-boundary> with auto-retry and exponential backoff
- friendlyError() maps raw errors to user-friendly messages + suggestions
- Supports severity levels (danger/warning/info), compact mode, dismiss
- Collapsible technical details section
- ARIA compliance with role=alert and aria-live
- Replaces all inline callout danger patterns across 23 view files
- Consistent error UX across agents, channels, sessions, config, etc.

* Web: reset retry timers on error changes (openclaw#273)

* Gateway: unify exec approvals with tool approval flow (openclaw#319)

* Gateway: unify exec approvals

* Gateway: guard exec approval resolves

* Feat/pr review monitor (openclaw#313)

* minor fixes

* feat: monitor AI PR review comments

* PR review monitor: add pagination config (openclaw#324)

* Codex/review branch changes and identify issues (openclaw#325)

* minor fixes

* feat: monitor AI PR review comments

* PR review monitor: add pagination config

* UI: reset auto-retry timers on error changes (openclaw#328)

* feat(ui): add error boundary component with retry & friendly messages

- New error-boundary.ts component with renderError/renderErrorIf helpers
- Custom element <error-boundary> with auto-retry and exponential backoff
- friendlyError() maps raw errors to user-friendly messages + suggestions
- Supports severity levels (danger/warning/info), compact mode, dismiss
- Collapsible technical details section
- ARIA compliance with role=alert and aria-live
- Replaces all inline callout danger patterns across 23 view files
- Consistent error UX across agents, channels, sessions, config, etc.

* Web: reset retry timers on error changes (openclaw#273)

* UI: reset auto-retry timers on error changes

* Add execution layer runtime parity gap analysis (openclaw#280)

* Add execution layer runtime parity gap analysis

Comprehensive analysis of Pi Runtime vs Claude Agent SDK feature
gaps in the unified execution layer, with 20 prioritized next steps.

https://claude.ai/code/session_017oEzmayzdirGAKmSw2ryQZ

* Meridia: wire multi-factor scoring into capture hook

* merge/minor fixes for ui/*

* Meridia: add per-capture graph fanout queue with retries

* Meridia: enforce sanitization before persistence and fanout

* Meridia: complete Tier2 vector probing and Postgres vector support

---------

Co-authored-by: Claude <[email protected]>

* Codex/review branch changes and identify issues (openclaw#325)

* minor fixes

* feat: monitor AI PR review comments

* PR review monitor: add pagination config

* Work queue: add heartbeat leases (openclaw#329)

* fix: duplicate lines on main

* Tools: clarify work_item refs and workstream (openclaw#332)

Co-authored-by: Claude Opus 4.6 <[email protected]>

* Config: clarify agents.list placement, accept agents.list in web import, and document guidance (openclaw#331)

* Config: clarify agents.list validation

* Web: tighten agents list import validation

* Sessions: align label limits (openclaw#333)

* Work queue: add work item refs support (openclaw#312)

* Tests: update migration count

* Tools: accept refs in work_item tool

* Work queue: link Codex tasks to PRs (post GitHub comments) (openclaw#337)

* Work queue: link codex tasks to PRs

* Work queue: skip branchPrefix-only PR lookup

* Claude/runtime orchestrator tools eu d uu (openclaw#327)

* feat(agents): add runtime tool-approval orchestrator with approvals.tools config

- Add approvals.tools config types + zod schema (enabled, mode, timeoutMs, policy, routing, classifier)
- Create tool-approval orchestrator module (decision engine, param redaction, gateway integration)
- Integrate orchestrator into before-tool-call wrapper path (runs after plugin hooks, before execution)
- Add ToolApprovalBlockedError with stable machine-readable error shape
- Add 90 tests covering all mode/decision/risk branches
- Backward-compatible: no behavior change when approvals.tools is missing or disabled

* feat: upgrade /approve and Discord handler to canonical tool approvals

- /approve now queries tool.approvals.get for canonical records and resolves
  via tool.approval.resolve (with requestHash); falls back to legacy
  exec.approval.resolve when no canonical record is found
- Discord handler listens for tool.approval.requested/resolved events and
  renders generic tool approval embeds for non-exec tools
- resolveApproval prefers tool.approval.resolve when requestHash is cached,
  keeping legacy exec path for backward compatibility
- Updated command description to 'tool approval requests'
- Added shouldHandleToolApproval for canonical event filtering
- Extended tests with canonical, legacy-fallback, and gateway-error scenarios

* refactor: rename .clawdbrain → .openclaw and fix repo/domain references

- Settings dir: ~/.clawdbrain → ~/.openclaw
- Repo references: openclaw/clawdbrain → dgarson/clawdbrain
- Domain: clawdbrain.bot → openclaw.ai
- CLI command: clawdbrain login → openclaw login
- 48 files changed across src/, docs/, apps/web/, ui/

* cron timeout fixes

* feat(agents): wire tool approval context from config into tool creation path

- Inject approvals.tools config into wrapToolWithBeforeToolCallHook context
- Populate channel field from messageProvider via resolveGatewayMessageChannel
- Wire callGatewayTool as the gateway call adapter for approval requests
- Approval context is only constructed when approvals.tools exists and is enabled

* fix: address review gaps in tool approval handler

- Exec dedup: store canonical request for exec tools and defer embed
  creation by 200ms so the legacy mirror gets first shot; if the mirror
  never arrives, fall back to a generic tool embed (future-proofs against
  legacy event removal)
- Extract sendToolApprovalEmbed to eliminate code duplication
- Add buildApprovalCustomId / parseApprovalData generic aliases (same
  wire format, clearer naming for non-exec tool code paths)
- Add alias identity tests

* fix: minor tool approval request fixes

* auto-reply/approval integration fix

* include exec approval doc

* fix: agent-runner-execution integration into auto-reply, executor/kernel fixes

* more work on agent runner and memory/heartbeta integration

* lots of tests resulting from unification of exec kernel; refactored

* Redact arrays in approval helper

* lancedb fixes

* more fixes/test updates

* fix: minor problem

* fix: restore proper non-throwing session label truncation

---------

Co-authored-by: Claude <[email protected]>

* Tool approval/protocol cleanup (openclaw#334)

* infra: consolidate tool approval types and clean protocol schema

* infra: bridge tool approval routing config into forwarder

* agents: enrich tool approval decision engine with config resolution and reason codes

* test: update tool approval tests for protocol and decision engine changes

* infra: consolidate tool approval types and clean protocol schema

* infra: bridge tool approval routing config into forwarder

* agents: enrich tool approval decision engine with config resolution and reason codes

* test: update tool approval tests for protocol and decision engine changes

* chore: conflict resolution

* chore: checkou tfrom main

* Codex/map paramssummary to exec command field (openclaw#342)

* infra: consolidate tool approval types and clean protocol schema

* infra: bridge tool approval routing config into forwarder

* agents: enrich tool approval decision engine with config resolution and reason codes

* test: update tool approval tests for protocol and decision engine changes

* infra: consolidate tool approval types and clean protocol schema

* infra: bridge tool approval routing config into forwarder

* agents: enrich tool approval decision engine with config resolution and reason codes

* test: update tool approval tests for protocol and decision engine changes

* chore: conflict resolution

* chore: checkou tfrom main

* Tool approvals: preserve exec command

* Codex/add web inbox for tool approvals (openclaw#339)

* Web: add tool approval inbox support

* Web: fallback approval resolution

* Web: fall back to agent approvals when IDs differ (openclaw#263)

* memclawd: scaffold phase 0 service foundation (openclaw#330)

* memclawd: apply oxfmt

* Memclawd: add client samples and align pipeline config

* Codex/implement work item refs system d2mkjz (openclaw#344)

* Tools: clarify work_item refs and workstream

* Tests: update migration count

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>

* Codex/review branch changes and identify issues kuj3uy (openclaw#343)

* Tests: update migration count

* Tools: accept refs in work_item tool

* Work queue: add refs reindex command

* Work queue: align refs migration and add refs-reindex CLI (openclaw#345)

* Tests: update migration count

* Work queue: move refs backfill to 004 migration

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants