Return {} for empty-string tool-call arguments in the interactions protocol - #911
Closed
pcbeingused333 wants to merge 1 commit into
Closed
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…otocol
Protocols::Interactions::Tools.parse_interaction_arguments ran
JSON.parse on any String, so a function_call step with
"arguments": "" raised ToolCallParseError and failed the whole run.
Protocols::ChatCompletions::Tools.parse_tool_call_arguments already
guards this with `arguments.nil? || arguments.empty?` -> {}; mirror it
so the two tool-call parsers agree.
Adds spec/ruby_llm/protocols/interactions/tools_spec.rb covering empty
string, missing key, hash passthrough, valid JSON, and malformed JSON.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018uqJtTJWawYLVA5EdpUmho
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #911 +/- ##
==========================================
+ Coverage 94.64% 94.65% +0.01%
==========================================
Files 312 312
Lines 15198 15199 +1
Branches 2710 2711 +1
==========================================
+ Hits 14384 14387 +3
+ Misses 310 309 -1
+ Partials 504 503 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
crmne
added a commit
that referenced
this pull request
Sep 13, 2026
Treat an empty argument string as a zero-argument tool call while preserving errors for malformed JSON. Integrates #911.
Owner
|
Integrated in c4b3afc3. Thanks for the fix and regression specs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Protocols::Interactions::Tools.parse_interaction_argumentsrunsJSON.parseon anyString:A
function_callstep whoseargumentsis an empty string ("") makesJSON.parse("")raise, so the whole run fails withToolCallParseErrorfor what is a valid zero-argument tool call.The sibling parser already handles this —
Protocols::ChatCompletions::Tools.parse_tool_call_arguments:So the two tool-call parsers disagree on the same input.
Fix
Guard empty (and nil) arguments in
parse_interaction_argumentsthe same way, beforeJSON.parse.Tests
New
spec/ruby_llm/protocols/interactions/tools_spec.rb: empty string →{}, missing key →{}, Hash passthrough, valid JSON object, malformed JSON →ToolCallParseError. The empty-string case raises onmain.bundle exec rspec spec/ruby_llm/protocols/interactions{_spec.rb,/tools_spec.rb} spec/ruby_llm/protocols/chat_completions/tools_spec.rb— green;rubocopclean on both files.