Skip to content

fix(tools): validate complete input contracts before execution - #187

Draft
1-ztc wants to merge 1 commit into
mainfrom
feat/tools_fix
Draft

1-ztc wants to merge 1 commit into
mainfrom
feat/tools_fix

Conversation

@1-ztc

@1-ztc 1-ztc commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Tool calls with invalid nested values currently reach implementations because execution only checks top-level parameter types. This change enforces JSON Schema at the existing execution boundaries, including rewritten hook and approval inputs, and consumes optional synchronous, idempotent safeParse adapters before validating their normalized output.

The validator supports draft-07, 2019-09 and 2020-12 without global coercion, default insertion, field removal or external schema loading. Validation messages omit rejected values and custom parser errors. Lean declarations preserve complex schemas instead of pruning them into unsatisfiable contracts.

Validation:

  • Reproduced the old runtime accepting invalid array items.
  • Passed 8 targeted schema/execution probe groups, tiny-window-surface, task-observation, full build, and changed-file ESLint/Prettier.
  • An independent Studio host smoke passed invalid-before-approval rejection, valid normalized execution, two reasoning configurations, and a zero-tool path using offline fixtures and no-op device implementations.
  • Full local verify was attempted but did not pass: cold whole-repository ESLint timed out after 10 minutes and todos-view failed on this macOS host. The same todos probe also failed against the unchanged official baseline 0afd8de with the same PTY output. These checks were not removed or bypassed.

Draft pending CI/review. Studio's official upstream pin remains unchanged until this change is merged into official main.

SDK: add optional Tool.inputZodSchema with a structural synchronous safeParse interface. Validate explicit canonical parser output against complete JSON Schema and require idempotence across approval and hook checks.

Intentional behavior tightening: arguments violating previously unenforced declared constraints now fail before execution. Preserve aliases, unknown-key compatibility and default/coercion ownership. Keep complex schemas intact in lean declarations.

Validation: tool-input-schema, tiny-window-surface and task-observation stages passed; changed-file ESLint and Prettier passed. Full verify was not green: cold whole-repository ESLint timed out and the todos-view PTY probe failed on both candidate and unchanged baseline.
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