Skip to content

fix(streaming): log warning when tool input JSON is malformed#2054

Open
Ratansairohith wants to merge 1 commit intostrands-agents:mainfrom
Ratansairohith:fix/malformed-tool-json-logging
Open

fix(streaming): log warning when tool input JSON is malformed#2054
Ratansairohith wants to merge 1 commit intostrands-agents:mainfrom
Ratansairohith:fix/malformed-tool-json-logging

Conversation

@Ratansairohith
Copy link
Copy Markdown

Fixes #2051

Changes

src/strands/event_loop/streaming.py:

  • Added logger.warning() in the except ValueError block (line 282) that logs the tool name and raw input string when JSON parsing fails. The fallback to {} is preserved.

tests/strands/event_loop/test_streaming.py:

  • Added a test case for malformed tool input JSON to verify the code path is covered.

Test plan

  • All 106 existing streaming tests pass
  • New test covers the malformed JSON path

Malformed tool input JSON was silently replaced with an empty dict,
with no logging. The tool then ran with empty arguments and the model
had no indication its JSON was invalid.

Added a logger.warning() call before the fallback so operators can
detect and diagnose this in production.

Fixes strands-agents#2051
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Malformed tool input JSON silently replaced with empty dict, no logging

1 participant