Skip to content

Conversation

@TimPansino
Copy link
Contributor

Overview

  • Add support for BedrockRuntime.converse_stream in botocore and boto3.

@TimPansino TimPansino requested a review from a team as a code owner October 31, 2025 20:06
@github-actions
Copy link

github-actions bot commented Oct 31, 2025

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 0.97s
✅ MARKDOWN markdownlint 7 0 0 0 1.31s
✅ PYTHON ruff 949 0 0 0 0.98s
✅ PYTHON ruff-format 949 0 0 0 0.32s
✅ YAML prettier 15 0 0 0 1.43s
✅ YAML v8r 15 0 0 5.61s
✅ YAML yamllint 15 0 0 0.69s

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security

@mergify mergify bot added the tests-failing Tests failing in CI. label Oct 31, 2025
@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 84.70588% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.82%. Comparing base (8d18c0a) to head (7a56608).

Files with missing lines Patch % Lines
newrelic/hooks/external_botocore.py 83.33% 7 Missing and 6 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1565   +/-   ##
=======================================
  Coverage   81.81%   81.82%           
=======================================
  Files         207      207           
  Lines       23953    23988   +35     
  Branches     3799     3808    +9     
=======================================
+ Hits        19597    19628   +31     
- Misses       3087     3090    +3     
- Partials     1269     1270    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TimPansino TimPansino force-pushed the feat-converse-streaming branch 3 times, most recently from 71d4d32 to d992b41 Compare October 31, 2025 21:23
@mergify mergify bot added merge-conflicts Merge conflicts detected. and removed tests-failing Tests failing in CI. labels Oct 31, 2025
@TimPansino TimPansino force-pushed the feat-converse-streaming branch from 472ec94 to c9ff7cb Compare November 4, 2025 21:31
@mergify mergify bot removed the merge-conflicts Merge conflicts detected. label Nov 4, 2025
"error.message": error_attributes.get("error.message"),
"error.code": error_attributes.get("error.code"),
}
notice_error_attributes.update({"completion_id": str(uuid.uuid4())})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
notice_error_attributes.update({"completion_id": str(uuid.uuid4())})
notice_error_attributes["completion_id"] = str(uuid.uuid4())})

Since this is just one pair being added to the dict, would direct access be more performant?

if "messageStop" in event:
bedrock_attrs["response.choices.finish_reason"] = (event.get("messageStop") or {}).get("stopReason", "")

# TODO: Is this also subject to the content_block_stop behavior from Langchain?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flagging this for discussion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to your changes but I noticed around line 762 the following code is missing a () after global_settings:

settings = transaction.settings or global_settings

Could you add that in while you're in here?



def extract_bedrock_converse_attrs(kwargs, response, response_headers, model, span_id, trace_id):
input_message_list = []
Copy link
Contributor

@umaannamalai umaannamalai Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input_message_list = []
input_message_list = []
output_message_list = None
# If a system message is supplied, it is under its own key in kwargs rather than with the other input messages
if "system" in kwargs.keys():
input_message_list.extend({"role": "system", "content": result["text"]} for result in kwargs.get("system", []))
# kwargs["messages"] can hold multiple requests and responses to maintain conversation history
# We grab the last message (the newest request) in the list each time, so we don't duplicate recorded data
_input_messages = kwargs.get("messages", [])
_input_messages = _input_messages and (_input_messages[-1] or {})
_input_messages = _input_messages.get("content", [])
input_message_list.extend(
[{"role": "user", "content": result["text"]} for result in _input_messages if "text" in result]
)

These changes were on the strands/ converse branch to prevent KeyErrors so we may want to port them into this branch.

@mergify mergify bot added the tests-failing Tests failing in CI. label Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests-failing Tests failing in CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants