Skip to content

fix(kiro): strip validation-only schema keywords rejected by runtimeservice#50

Merged
lidge-jun merged 1 commit into
devfrom
codex/kiro-memory-tool-schema
Jun 29, 2026
Merged

fix(kiro): strip validation-only schema keywords rejected by runtimeservice#50
lidge-jun merged 1 commit into
devfrom
codex/kiro-memory-tool-schema

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Kiro's runtimeservice tool-spec validator rejects requests with ValidationException: Invalid tool use format. whenever a tool's input schema carries JSON Schema validation keywords. codex-rs memories__* 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 sanitizeKiroSchema only stripped additionalProperties and empty required.

Changes

  • Drop the full set of validation/applicator keywords Bedrock/Kiro do not support: pattern, format, length/range bounds, patternProperties, propertyNames, dependentSchemas, if/then/else, etc.
  • Preserve structural keywords (type, properties, items, enum, required, $ref/$defs).
  • Recurse into property/definition name maps without treating their child names as keywords, so a property literally named format/pattern survives.

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 fail
  • bun x tsc --noEmit -> clean
  • bun run privacy:scan -> passed
  • Added tests covering keyword stripping, property-name preservation, and $defs retention.
  • Independently reviewed via gpt-5.5 (flagged patternProperties retention, now fixed).

…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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@lidge-jun lidge-jun merged commit c49fb9e into dev Jun 29, 2026
6 checks passed
@lidge-jun lidge-jun deleted the codex/kiro-memory-tool-schema branch June 29, 2026 21:24
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.

1 participant