Repository navigation
fix(crew): don't report a successful tool call as failed when its result isn't JSON-native - #158
Open
Shraman123 wants to merge 1 commit into
Open
Shraman123 wants to merge 1 commit into
Shraman123 wants to merge 1 commit into
Conversation
…ult isn't JSON-native
ToolRegistry._execute_single serialized dict/list results with a bare
json.dumps, so a tool returning e.g. {"at": datetime(...)} raised after
the tool had already run. The except branch then emitted tool_call_error
and returned is_error=True ("Object of type datetime is not JSON
serializable") to the LLM, which for a booking/payment tool invites a
retry that repeats the side effect.
Serialize with default=str so datetime / Decimal / UUID etc. come through
as strings. Plain JSON results are byte-identical.
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
ToolRegistry._execute_singleserializes dict/list tool results with a barejson.dumps(result). If the result contains adatetime,Decimal,UUID, … that call raises after the tool has already run, and theexceptbranch turns a successful call into a failure:tool_call_erroris emitted instead oftool_call_endis_error=Truewith"Object of type datetime is not JSON serializable"For a tool with side effects (booking, payment, CRM write) that invites the model to call it again and repeat the side effect.
Repro on
main:Fix
json.dumps(result, default=str). Non-JSON-native values come through as their string form. Results that are already plain JSON serialize byte-identically. One-line change insrc/smallestai/atoms/crew/tools/registry.py(.fernignored).Tests
New
tests/custom/test_tool_registry_result_serialization.py:is_error=False, correct content, eventstool_call_start→tool_call_end(fails onmain)pytest 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