Skip to content

Conversation

@thpierce
Copy link
Contributor

@thpierce thpierce commented Oct 17, 2025

_decode_tool_use was only used when _tool_json_input_buf was found, but we were decoding the entire _content_block after adding _tool_json_input_buf to it. The _content_block overall which could contain non-JSON elements (e.g. {}), causing failures. To fix this, we have removed _decode_tool_use helper function and inlined JSON decoding logic directly into content_block_stop handler in _process_anthropic_claude_chunk, where we only use it to decode _tool_json_input_buf before appending to _content_block.

Patch based on open-telemetry/opentelemetry-python-contrib#3875 with code copied directly from https://github.com/open-telemetry/opentelemetry-python-contrib/blob/v0.54b1/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py#L289

Repeated testing in open-telemetry/opentelemetry-python-contrib#3875 to confirm this works

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@thpierce thpierce requested a review from a team as a code owner October 17, 2025 21:37
_decode_tool_use was only used when _tool_json_input_buf was found, but we were decoding the entire _content_block after adding _tool_json_input_buf to it. The _content_block overall which could contain non-JSON elements (e.g. {}), causing failures. To fix this, we have removed _decode_tool_use helper function and inlined JSON decoding logic directly into content_block_stop handler in _process_anthropic_claude_chunk, where we only use it to decode _tool_json_input_buf before appending to _content_block.

Patch based on open-telemetry/opentelemetry-python-contrib#3875 with code copied directly from https://github.com/open-telemetry/opentelemetry-python-contrib/blob/v0.54b1/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py#L289
srprash
srprash previously approved these changes Oct 17, 2025
@thpierce thpierce merged commit d6c6cb1 into main Oct 21, 2025
36 of 60 checks passed
@thpierce thpierce deleted the bedrock-patch branch October 21, 2025 22:52
jj22ee pushed a commit to jj22ee/aws-otel-python-instrumentation that referenced this pull request Oct 22, 2025
…rvability#497)

_decode_tool_use was only used when _tool_json_input_buf was found, but
we were decoding the entire _content_block after adding
_tool_json_input_buf to it. The _content_block overall which could
contain non-JSON elements (e.g. {}), causing failures. To fix this, we
have removed _decode_tool_use helper function and inlined JSON decoding
logic directly into content_block_stop handler in
_process_anthropic_claude_chunk, where we only use it to decode
_tool_json_input_buf before appending to _content_block.

Patch based on
open-telemetry/opentelemetry-python-contrib#3875
with code copied directly from
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/v0.54b1/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py#L289

Repeated testing in
open-telemetry/opentelemetry-python-contrib#3875
to confirm this works

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
jj22ee pushed a commit to jj22ee/aws-otel-python-instrumentation that referenced this pull request Oct 22, 2025
…rvability#497)

_decode_tool_use was only used when _tool_json_input_buf was found, but
we were decoding the entire _content_block after adding
_tool_json_input_buf to it. The _content_block overall which could
contain non-JSON elements (e.g. {}), causing failures. To fix this, we
have removed _decode_tool_use helper function and inlined JSON decoding
logic directly into content_block_stop handler in
_process_anthropic_claude_chunk, where we only use it to decode
_tool_json_input_buf before appending to _content_block.

Patch based on
open-telemetry/opentelemetry-python-contrib#3875
with code copied directly from
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/v0.54b1/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py#L289

Repeated testing in
open-telemetry/opentelemetry-python-contrib#3875
to confirm this works

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
jj22ee added a commit that referenced this pull request Oct 22, 2025
*Issue #, if available:*
Cherry-picks:
-
#477
-
#497

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: Thomas Pierce <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants