fix(kiro): strip validation-only schema keywords rejected by runtimeservice#50
Conversation
…ervice codex-rs memories__* tools (add_ad_hoc_note/read/search/list) emit JSON Schema validation keywords (pattern, minLength/maxLength, minimum, minItems) via schemars. Kiro's runtimeservice tool-spec validator rejects these with "ValidationException: Invalid tool use format", breaking every memory tool call. sanitizeKiroSchema now drops the full set of validation/applicator keywords Bedrock/Kiro do not support (pattern, format, length/range bounds, patternProperties, propertyNames, if/then/else, etc.) while preserving structural keywords (type, properties, items, enum, required, $ref/$defs). Property and definition name maps are recursed into without treating their child names as keywords, so a property literally named "format"/"pattern" survives.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a33e4a5cc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const out: Record<string, unknown> = {}; | ||
| for (const [key, child] of Object.entries(value as Record<string, unknown>)) { | ||
| if (key === "additionalProperties") continue; | ||
| if (KIRO_REJECTED_SCHEMA_KEYS.has(key)) continue; |
There was a problem hiding this comment.
Preserve property-map keys while flattening root composition
When a tool schema has root oneOf/anyOf/allOf, ensureRootObjectType later calls sanitizeKiroSchema directly on obj.properties and each variant's properties map, so this global rejected-key check is applied to property names instead of schema keywords. In that scenario, a legitimate argument named format, pattern, minimum, etc. is dropped from the advertised tool schema (and can even remain in required without a property definition), despite the new sanitizeSchemaMap path preserving those names for non-composed root schemas.
Useful? React with 👍 / 👎.
Summary
Kiro's
runtimeservicetool-spec validator rejects requests withValidationException: Invalid tool use format.whenever a tool's input schema carries JSON Schema validation keywords. codex-rsmemories__*tools (add_ad_hoc_note,read,search,list) emit these via schemars (pattern,minLength/maxLength,minimum,minItems), so every memory tool call failed with HTTP 400.The previous
sanitizeKiroSchemaonly strippedadditionalPropertiesand emptyrequired.Changes
pattern,format, length/range bounds,patternProperties,propertyNames,dependentSchemas,if/then/else, etc.type,properties,items,enum,required,$ref/$defs).format/patternsurvives.Why it's safe
These constraints are advisory hints for the model only; dropping them does not change tool behavior. Out-of-format args (e.g. a bad
filename) are still corrected by the codex-rs backend (InvalidFilename-> RespondToModel). Change is confined to the Kiro adapter; anthropic/google schema paths are untouched.Testing
bun test ./tests/-> 892 pass / 0 failbun x tsc --noEmit-> cleanbun run privacy:scan-> passedpatternPropertiesretention, now fixed).