docs(schema): decompose tool call payload union#8
Conversation
|
Warning Review limit reached
More reviews will be available in 16 minutes and 59 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Ready to review this PR? Stage has broken it down into 5 individual chapters for you: Chapters generated by Stage for commit 55ebf63 on Jun 13, 2026 11:12am UTC. |
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Schema as JSON Schema (draft/2020-12)
participant Validator as AJV Validator
participant Gen as json-schema-to-typescript
participant TSC as TypeScript Compiler
participant Tools as Tool Definitions ($defs)
Note over Schema,Tools: CHANGED: tool_call.payload decomposed from oneOf of 32 branches to allOf composition
Schema->>Schema: Define tool discriminator schema (tool const per tool kind)
Schema->>Schema: Define common fields schema (usage, truncated, args_size, overflow_ref)
Schema->>Schema: Define truncation state schemas (truncated: true vs false)
Schema->>Tools: Reference tool-specific args $ref (toolCallFileReadArgs, etc.)
Note over Schema: NEW: allOf combines discriminator + common fields + truncation state
Schema->>Schema: Apply unevaluatedProperties: false at payload top level
Validator->>Schema: Load schema
Validator->>Schema: Validate tool_call payload against allOf composition
alt Valid tool_call payload
Validator->>Validator: Discriminator matches one tool const
Validator->>Validator: Common fields present
Validator->>Validator: Truncation state consistent (args_size required when truncated=true)
Validator-->>Validator: Pass
else Unknown top-level field (e.g., "future_field")
Validator->>Schema: unevaluatedProperties: false rejects extra field
Validator-->>Validator: Fail (validation error)
end
Note over Gen,TSC: NEW: Pinned json-schema-to-typescript@15.0.4 generation guard
Gen->>Schema: Compile schema/v0.1.0.json to TypeScript types
Gen-->>Gen: Generate AgentTrailV010 type with allOf composition (not oneOf expansion)
TSC->>Gen: Run check-typescript-generation.mjs script
Gen->>Gen: Fork child process to load json-schema-to-typescript
Gen-->>TSC: Generated TypeScript source (~178ms)
TSC->>TSC: Compile smoke contracts (validShellTruncated, invalidShellMissingArgsSize, etc.)
alt Valid smoke contracts
TSC-->>TSC: @ts-expect-error annotations pass for invalid cases
TSC-->>TSC: Valid cases compile without error
else Smoke contract failure
TSC-->>TSC: Compilation error (test fails)
end
TSC->>Validator: Run assertSchemaRejectsUnknownToolPayloadField via AJV
Validator->>Schema: Validate sample with unknown top-level field
alt Schema rejects unknown field
Validator-->>TSC: exit code 1 (expected)
TSC-->>TSC: Pass
else Schema allows unknown field
Validator-->>TSC: exit code 0 (unexpected)
TSC-->>TSC: Fail with error
end
Note over Schema,Tools: Validation semantics preserved (459 fixture records unchanged)
Shadow auto-approve: would require human review. Schema refactor replacing 32 oneOf branches with allOf composition alters the generated TypeScript types and validation behavior. Though tests pass, composition changes in a JSON schema can have subtle downstream effects on type generation and strictness that warrant human review.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Pull Request
Summary
tool_call.payloadfrom 32 full payload branches intoallOfof tool discriminator, common fields, and truncation state.unevaluatedProperties: falseso unknown top-level tool payload fields remain invalid.json-schema-to-typescript@15.0.4generation guard and TypeScript smoke contracts.Related Issue
Public Impact
Impact description:
oneOfexpansion.Verification
mise run check:typescript-generationpassed. Generation completed in ~178ms locally.mise run check:schemapassed.file_read.args.path, unknown tool payload field rejection, capability JSON values, and vendor metadata JSON values.mise run checkpassed.cmp -s schema/draft.json schema/v0.1.0.jsonpassed.Reviewer Notes
allOfcomposition.