Repository navigation
fix(crew): treat empty tool-call arguments as no arguments - #157
Open
Shraman123 wants to merge 1 commit into
Open
Shraman123 wants to merge 1 commit into
Shraman123 wants to merge 1 commit into
Conversation
OpenAIClient accumulates streamed argument deltas from "" and skips empty
ones, so a call to a zero-parameter tool (end_call, transfer, ...) from a
provider that streams no argument text arrives with arguments == "".
json.loads("") raised, the tool never ran, and the LLM got "Expecting
value: line 1 column 1 (char 0)" back as a tool error.
Parse empty/blank arguments as {}. Malformed JSON is still an error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
crim doesn't review pull requests automatically here. Comment |
This branch has not been deployed
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
OpenAIClientaccumulates streamed tool-call argument deltas starting from""and skips empty deltas, so a call to a zero-parameter tool (end_call,transfer, …) from a provider that streams no argument text arrives witharguments == "".ToolRegistry._execute_singlethen doesjson.loads(""), which raises: the tool never runs and the LLM getsExpecting value: line 1 column 1 (char 0)back as a tool error.Repro on
main:Fix
Empty / whitespace-only
argumentsare parsed as{}. Malformed JSON is still reported as an error, as before. Change is insrc/smallestai/atoms/crew/tools/registry.py(.fernignored).Tests
New
tests/custom/test_tool_registry_empty_arguments.py:""," ","{}"→ the tool runs,is_error=False(the first two fail onmain)is_error=Truewith the call's idpytest tests/custom: 280 passed; the only 2 failures (test_region_aware_auth) fail identically onmainlocally and are unrelated.ruff checkclean on the changed files.🤖 Generated with Claude Code