-
Notifications
You must be signed in to change notification settings - Fork 757
opentelemetry-instrumentation-botocore: fix handling of tool input chunked json in bedrock converse_stream #3544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
…unked json in converse_stream We need to accumulate all the tool input as string before decoding it otherwise we may end up with invalid json.
xrmx
commented
May 27, 2025
instrumentation/opentelemetry-instrumentation-botocore/tests/bedrock_utils.py
Show resolved
Hide resolved
SrdjanLL
reviewed
May 27, 2025
instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py
Show resolved
Hide resolved
...trumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py
Show resolved
Hide resolved
SrdjanLL
approved these changes
May 27, 2025
aabmass
approved these changes
May 28, 2025
liustve
added a commit
to aws-observability/aws-otel-python-instrumentation
that referenced
this pull request
Jul 25, 2025
*Description of changes:* This PR applies temporary patches to address critical bugs in the AWS Bedrock runtime botocore instrumentation (version 0.54b0) that affect tool use functionality in non-streaming responses reported in: strands-agents/sdk-python#488 These changes are temporary patches and should be removed once we upgrade to `opentelemetry-instrumentation-botocore` version 0.56b0, which includes official fixes for these issues. See: open-telemetry/opentelemetry-python-contrib#3548 open-telemetry/opentelemetry-python-contrib#3544 *Testing Done* - Unit tests added - Validated with Bedrock AgentCore team that fixes work. - Ran a sample app with Bedrock AgentCore and strands framework and validated that expected toolUse output is correct: Before fix: ``` Tool use: {"input": ""} Tool use: {"input": "{\"input\": 99"} Tool use: {"input": 999} Tool use: {"input": 99999} Tool use: {"input": 9999} Tool use: {"input": 9999} Tool use: {"input": ", \"input2"} Tool use: {"input": "\": 8"} Tool use: {"input": 888888888888} Tool use: {"input": 888} Tool use: {"input": "88}"} ``` After fix: ``` Tool use: {"input": ""} Tool use: {"input": "{\"in"} Tool use: {"input": "put\": 9"} Tool use: {"input": "99"} Tool use: {"input": "99"} Tool use: {"input": "99"} Tool use: {"input": "9999"} Tool use: {"input": "99999"} Tool use: {"input": "99"} Tool use: {"input": ", \"input"} Tool use: {"input": "2\":"} Tool use: {"input": " 8"} Tool use: {"input": "888888"} Tool use: {"input": "888888888"} Tool use: {"input": "88}"} ``` By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
devmonkey22
pushed a commit
to devmonkey22/opentelemetry-python-contrib
that referenced
this pull request
Aug 5, 2025
…unked json in bedrock converse_stream (open-telemetry#3544) * opentelemetry-instrumentation-botocore: fix handling of tool input chunked json in converse_stream We need to accumulate all the tool input as string before decoding it otherwise we may end up with invalid json. * Add changelog * Remove leftover print * No need for too-many-statements disable
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.
Description
We need to accumulate all the tool input as string before decoding it otherwise we may end up with invalid json.
Fixes #3537
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.