Fix #6149: Parse accumulated tool input in Bedrock streaming - #6151
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Fix #6149: Parse accumulated tool input in Bedrock streaming#6151devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
In _handle_streaming_converse and _ahandle_streaming_converse, the
accumulated_tool_input string was never folded back into
current_tool_use['input'] at contentBlockStop, causing tool calls to
receive empty arguments ({}).
Parse the accumulated JSON string and assign it to
current_tool_use['input'] before reading function_args.
Co-Authored-By: João <joao@crewai.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| mock_stream.return_value = {"stream": iter(stream_events)} | ||
| mock_converse.return_value = final_response | ||
|
|
||
| result = llm.call( |
| mock_stream.return_value = {"stream": iter(stream_events)} | ||
| mock_converse.return_value = final_response | ||
|
|
||
| result = llm.call( |
| with patch.object(llm, "_ensure_async_client", side_effect=fake_ensure), \ | ||
| patch.object(llm, "_ahandle_converse", side_effect=fake_ahandle_converse): | ||
| messages = [{"role": "user", "content": "Weather in London?"}] | ||
| result = await llm.acall( |
Contributor
|
This PR is stale because it has been open for 45 days with no activity. |
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.
Summary
Fixes #6149 — Bedrock streaming tool calls receive empty arguments (
{}).In both
_handle_streaming_converse(sync) and_ahandle_streaming_converse(async), the tool input JSON deltas were accumulated intoaccumulated_tool_inputduringcontentBlockDeltaevents, but never parsed and stored back intocurrent_tool_use["input"]atcontentBlockStop. This causedcurrent_tool_use.get("input", {})to return{}, so the tool executor received no arguments.The fix parses
accumulated_tool_inputviajson.loads()and assigns it tocurrent_tool_use["input"]atcontentBlockStop, beforefunction_argsis read:This also ensures the
toolUseblock appended to messages for the follow-up converse call carries the correctinput.Tests added: 4 new tests covering sync (single-chunk, multi-chunk, split-across-many-chunks) and async streaming tool-call argument parsing. All 39 bedrock tests pass.
Link to Devin session: https://app.devin.ai/sessions/e9f126a256fb489491180316ca156300