Skip to content

fix: reject tool calls with missing arguments instead of running empty (#83) - #101

Merged
ajianaz merged 1 commit into
developfrom
fix/invalid-tool-args
Sep 19, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/invalid-tool-args

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

What

Provider-layer fix: a tool_call whose function.arguments field is missing, null, or a blank string now surfaces as ProviderOutput::InvalidToolArgs (reason: "missing arguments") instead of silently running the tool with empty input. Also accepts object-shaped arguments (some gateways emit a JSON object rather than a string) and tolerates surrounding whitespace when parsing.

Why

Issue #83: the old _ => "{}" fallback treated a malformed call as an empty one — write_file recorded input: {}, failed with missing 'path', and the model retried the identical empty call until the loop guard tripped. Re-confirmed live today (2026-09-19, installed v0.3.0 vs glm-5.3-flash via Bifrost): the approval prompt showed what: write file <missing path> with input: {}. A missing-arguments call is a malformed call, not an empty one.

Changes

  • parse_completion: missing/null/blank arguments → InvalidToolArgs { reason: "missing arguments" }; object/array-shaped arguments serialized through the normal parse path; args.trim() parse (fixes a blank-string crash class too)
  • New regression test parse_completion_missing_arguments_is_invalid_not_empty covering missing / null / blank (assert InvalidToolArgs) + object-shaped (assert normal ToolCall)
  • Reuses the existing InvalidToolArgs settlement path in the turn loop — the model sees the parse error and can retry well-formed (no new plumbing)

Testing

  • cargo fmt --all / cargo clippy --workspace --all-targets -- -D warnings ✅
  • cargo test --workspace ✅ (207 tests, exit 0; new test green: parse_completion_missing_arguments_is_invalid_not_empty ... ok)
  • cora review --staged ✅ No issues found
  • Live E2E evidence for the bug itself: fresh tole run today reproduced input: {} + <missing path> on the approval prompt (deny path, fail-closed held — no file written)

Closes #83

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 5363828 into develop Sep 19, 2026
16 checks passed
@ajianaz
ajianaz deleted the fix/invalid-tool-args branch September 19, 2026 05:33
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.

Provider: tool_call with missing 'arguments' silently runs the tool with empty input (loop)

1 participant