Skip to content

fix(tools): normalize optional fillers before validation - #1523

Merged
anandgupta42 merged 5 commits into
feat/analyst-harness-dab-2026-10from
fix/filler-safe-tool-params
Oct 16, 2026
Merged

anandgupta42 merged 5 commits into
feat/analyst-harness-dab-2026-10from
fix/filler-safe-tool-params

Conversation

@anandgupta42

@anandgupta42 anandgupta42 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1495

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Stacked on feat/analyst-harness-dab-2026-10 (#1441).

Why. Strict-schema model clients send every optional tool property, filling unused ones with "", [], 0 or null. These were validated as real values, so valid calls were rejected (zero row limit, empty arrays against minimum-length schemas, null) or behaved unsafely (a zero query timeout disables the deadline in the drivers).

Root cause. The shared tool wrapper, the legacy zod adapter and plugin tools all validated raw arguments with no optional-filler contract; the SQL tool schemas also accepted zero timeouts and rejected oversized caps.

Before -> after.

  • Top-level optional [], "", 0, null that make validation fail are treated as omitted and validation is retried (new fillerSafeParameters), for native, legacy and plugin tools. Required fields, nested payloads, explicit false and nonempty/positive values are unchanged.
  • sql_execute, sql_materialize, sql_check: filler timeouts keep the configured deadline instead of disabling it; positive overrides still work.
  • sql_execute.limit: 0 uses the default; oversized values clamp to 10,000 instead of failing.
  • sql_materialize byte budget: oversized values reach the existing hard cap instead of failing schema validation.
  • sql_check: coverage still requires an explicit pattern (empty pattern stays meaningful); published schema stays flat for strict providers.

Fallback, not unconditional stripping. Arguments are validated as sent first, so schema-valid intentional values (max_entries: 0, description: "", integration_ids: []) are preserved. Only a call the schema rejects is retried, dropping just the top-level optional "", [], 0, null values that are not valid on their own and keeping valid siblings. SQL tool query_timeout_ms now requires a positive value, so a filler 0 falls back to the configured deadline (an explicit 0 no longer disables the deadline through these tools).

Known limits / follow-ups (P2).

  • Plugin tools: the handler receives normalized arguments only when they validate (unlisted arguments are kept; otherwise raw arguments are passed, as before). In batch, plugin arguments are still decoded twice, which breaks input-changing transforms.
  • The tool.definition plugin hook output may not reach the published JSON schema because it is captured before the hook runs.
  • When several fillers are individually valid but invalid together, the retry drops all of them; the retry also runs the decoder once per filler candidate (cost only on the failure path).
  • Nested payload fillers are not rewritten (could alter intentional data).

How did you verify your code works?

  • New and updated tests: test/tool/filler-parameters.test.ts (registry-wide fillers, native/legacy/plugin execution, union discriminants), sql-execute, sql-materialize, sql-check. Each touched file passes in isolation (5, 47, 58, 63 tests; 0 fail); new test covers valid empty/zero values preserved and rejected fillers still accepted; test/tool/registry.test.ts 14 pass.
  • bun test test/tool test/altimate/tools plus the sql-materialize suites: 1399 pass, 4 fail, 2 errors in one combined run. Failures are 5s hook timeouts under load (all pass when rerun alone) and two pre-existing failures that also fail at the base commit (datamate-list-integrations, project-scan).
  • bun run typecheck passes; git diff --check clean.
  • Upstream markers: changed upstream-shared files src/tool/tool.ts and src/tool/registry.ts (present at the v1 baseline tag) have every added line inside altimate_change blocks, none nested.
  • Not run: live provider session.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

🤖 Generated with Claude Code


Note

Medium Risk
Changes shared tool argument decoding for all tools and alters SQL timeout/limit/cap semantics, which can affect agent tool calls and query execution boundaries.

Overview
Adds fillerSafeParameters so strict-schema clients can send every optional field as "", [], 0, or null without failing validation: arguments are decoded as sent first, and only on failure are top-level optional fillers stripped and decode retried. This is wired into native tools (Tool.wrap), legacy zod tools (tool-zod-compat), and plugin tools (fillerSafePlugin in the registry).

SQL tool behavior is tightened alongside that: filler query_timeout_ms no longer disables deadlines (positive values only at schema level; omit/0 → connection default). sql_execute treats limit: 0 like omitted/default, and clamps oversized limits to 10k instead of rejecting. sql_check validates with a discriminated union (coverage still requires pattern) but publishes a flat wire schema for strict providers. sql_materialize drops the JSON-schema max on max_bytes so huge values clamp at execution (tests updated).

New test/tool/filler-parameters.test.ts plus updates to sql-execute, sql-check, and sql-materialize tests cover registry-wide fillers and the new normalization paths.

Reviewed by Cursor Bugbot for commit 01c89ca. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Fixes valid tool calls being rejected by strict-schema model clients, which send every optional property filled with "", [], 0, or null. Arguments are validated as sent first; only when that fails are top-level optional fillers treated as omitted in a retry via the new fillerSafeParameters, so defaults and constraints behave as if the field were not sent. Intentional 0/""/[] values that validate are preserved, and valid fillers stay when an unrelated one is rejected. Closes #1495.

Behavior changes

  • Filler query timeouts keep the configured deadline; positive overrides still apply.
  • sql_execute limit 0 uses the default; values over 10,000 clamp instead of failing.
  • sql_materialize byte budgets over the 2 GiB cap clamp instead of failing validation.
  • sql_check coverage still requires an explicit pattern; the published JSON schema stays flat for strict providers.
  • Plugin tools pass normalized arguments only when they validate, keep unlisted arguments, and otherwise hand the handler the arguments as sent.

Written for commit 01c89ca. Summary will update on new commits.

View guided diff Turn on auto-fix

Strict-schema clients send every optional property, using "", [], 0 or
null for the ones they do not intend to set. These were validated as real
values, so valid calls were rejected or got unsafe behavior (e.g. a zero
query timeout disables the deadline).

- add `fillerSafeParameters`: top-level optional `[]`, `""`, `0`, `null`
  are treated as omitted before validation and defaults
- apply it in the shared tool wrapper, the legacy zod adapter and plugin
  tools
- SQL tools: filler timeouts keep the configured deadline, zero row limit
  uses the default, oversized row limits and byte budgets clamp
- `sql_check`: coverage still requires an explicit `pattern`
- add regression tests for registry-wide fillers and the SQL tools

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8a04b671-7e2a-4712-bc92-94af062f2a74

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Oct 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 09f3ae64-0f73-4563-b680-918cc2da40db)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T03:40:50.454656Z 01c89ca New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@kilo-code-bot

kilo-code-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (11 files)
  • packages/opencode/src/altimate/tool-zod-compat.ts
  • packages/opencode/src/altimate/tools/sql-check.ts
  • packages/opencode/src/altimate/tools/sql-execute.ts
  • packages/opencode/src/altimate/tools/sql-materialize.ts
  • packages/opencode/src/tool/filler-parameters.ts
  • packages/opencode/src/tool/registry.ts
  • packages/opencode/src/tool/tool.ts
  • packages/opencode/test/altimate/sql-materialize.test.ts
  • packages/opencode/test/altimate/tools/sql-check.test.ts
  • packages/opencode/test/altimate/tools/sql-execute.test.ts
  • packages/opencode/test/tool/filler-parameters.test.ts
Previous Review Summaries (3 snapshots, latest commit 335b9eb)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 335b9eb)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (11 files)
  • packages/opencode/src/altimate/tool-zod-compat.ts
  • packages/opencode/src/altimate/tools/sql-check.ts
  • packages/opencode/src/altimate/tools/sql-execute.ts
  • packages/opencode/src/altimate/tools/sql-materialize.ts
  • packages/opencode/src/tool/filler-parameters.ts
  • packages/opencode/src/tool/registry.ts
  • packages/opencode/src/tool/tool.ts
  • packages/opencode/test/altimate/sql-materialize.test.ts
  • packages/opencode/test/altimate/tools/sql-check.test.ts
  • packages/opencode/test/altimate/tools/sql-execute.test.ts
  • packages/opencode/test/tool/filler-parameters.test.ts

Previous review (commit aa8bc0e)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (11 files)
  • packages/opencode/src/altimate/tool-zod-compat.ts
  • packages/opencode/src/altimate/tools/sql-check.ts
  • packages/opencode/src/altimate/tools/sql-execute.ts
  • packages/opencode/src/altimate/tools/sql-materialize.ts
  • packages/opencode/src/tool/filler-parameters.ts
  • packages/opencode/src/tool/registry.ts
  • packages/opencode/src/tool/tool.ts
  • packages/opencode/test/altimate/sql-materialize.test.ts
  • packages/opencode/test/altimate/tools/sql-check.test.ts
  • packages/opencode/test/altimate/tools/sql-execute.test.ts
  • packages/opencode/test/tool/filler-parameters.test.ts

Previous review (commit af1174b)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (11 files)
  • packages/opencode/src/altimate/tool-zod-compat.ts
  • packages/opencode/src/altimate/tools/sql-check.ts
  • packages/opencode/src/altimate/tools/sql-execute.ts
  • packages/opencode/src/altimate/tools/sql-materialize.ts
  • packages/opencode/src/tool/filler-parameters.ts
  • packages/opencode/src/tool/registry.ts
  • packages/opencode/src/tool/tool.ts
  • packages/opencode/test/altimate/sql-materialize.test.ts
  • packages/opencode/test/altimate/tools/sql-check.test.ts
  • packages/opencode/test/altimate/tools/sql-execute.test.ts
  • packages/opencode/test/tool/filler-parameters.test.ts

Reviewed by gemini-4-argon · Input: 59.6K · Output: 1.4K · Cached: 193.9K

Review guidance: REVIEW.md from base branch feat/analyst-harness-dab-2026-10

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/opencode/src/tool/filler-parameters.ts
Comment thread packages/opencode/src/tool/tool.ts
Comment thread packages/opencode/src/tool/registry.ts Outdated

@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: af1174b6c3

ℹ️ 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".

Comment thread packages/opencode/src/tool/filler-parameters.ts Outdated
Comment thread packages/opencode/src/tool/registry.ts Outdated
Comment thread packages/opencode/src/tool/tool.ts
Validate arguments as sent first so schema-valid intentional values
(`max_entries: 0`, `description: ""`, `integration_ids: []`) are preserved.
Only a call the schema rejects is retried with top-level optional fillers
removed.

- `fillerSafeParameters` is now a union of the original schema and the
  stripped-retry schema
- SQL tool `query_timeout_ms` now requires a positive value, so a filler
  `0` falls back to the configured deadline
- tests: valid empty/zero values preserved, rejected fillers still accepted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: d50420d0-896c-4a97-8918-915803f5c7b6)

@anandgupta42

Copy link
Copy Markdown
Contributor Author

Pushed aa8bc0e: arguments are now validated as sent first; optional fillers are stripped only when validation fails. Schema-valid intentional values (zero, empty string, empty array) are preserved. SQL tool timeouts require a positive value so filler zeros fall back to the configured deadline. Deferred P1 removed from the description.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 5 files (changes from recent commits).

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/opencode/test/tool/filler-parameters.test.ts Outdated

@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: aa8bc0e94f

ℹ️ 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".

Comment thread packages/opencode/src/tool/filler-parameters.ts
When validation fails, retry keeping each optional filler that is valid on
its own and dropping only the rejected ones, instead of stripping all
fillers. Intentional zero/empty values next to an unrelated filler survive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 197e66d3-ff12-4317-9321-b5cee6501d5f)

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/opencode/src/tool/filler-parameters.ts
Comment thread packages/opencode/src/tool/filler-parameters.ts
Plugin handlers historically received raw arguments. Use the normalized
arguments only when they validate, keep arguments the schema does not
list, and otherwise hand the handler the arguments as sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 92c8a122-11a8-4d91-b9cf-dee7c920705f)

@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 0d340663-0540-4d89-9b6d-5e83303daa7c)

@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@anandgupta42
anandgupta42 merged commit dad62eb into feat/analyst-harness-dab-2026-10 Oct 16, 2026
11 checks passed
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant