diff --git a/lib/crewai/src/crewai/llms/providers/bedrock/completion.py b/lib/crewai/src/crewai/llms/providers/bedrock/completion.py index cd323eac00..2c7912b1da 100644 --- a/lib/crewai/src/crewai/llms/providers/bedrock/completion.py +++ b/lib/crewai/src/crewai/llms/providers/bedrock/completion.py @@ -1054,6 +1054,13 @@ def _handle_streaming_converse( logging.debug("Content block stopped in stream") if current_tool_use: function_name = current_tool_use["name"] + # accumulated_tool_input holds the full JSON string for streaming tool calls. + # Parse it back to a dict; fall back to empty dict on failure. + if accumulated_tool_input: + try: + current_tool_use["input"] = json.loads(accumulated_tool_input) + except (json.JSONDecodeError, ValueError): + current_tool_use["input"] = {} function_args = cast( dict[str, Any], current_tool_use.get("input", {}) ) @@ -1636,6 +1643,13 @@ async def _ahandle_streaming_converse( logging.debug("Content block stopped in stream") if current_tool_use: function_name = current_tool_use["name"] + # accumulated_tool_input holds the full JSON string for streaming tool calls. + # Parse it back to a dict; fall back to empty dict on failure. + if accumulated_tool_input: + try: + current_tool_use["input"] = json.loads(accumulated_tool_input) + except (json.JSONDecodeError, ValueError): + current_tool_use["input"] = {} function_args = cast( dict[str, Any], current_tool_use.get("input", {}) )