Skip to content

Conversation

@umaannamalai
Copy link
Contributor

This PR adds instrumentation for Strands tools and agents. It also includes tests for single agent use cases.

@github-actions
Copy link

github-actions bot commented Oct 30, 2025

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 0.92s
✅ MARKDOWN markdownlint 7 0 0 0 1.37s
✅ PYTHON ruff 953 0 0 0 1.04s
✅ PYTHON ruff-format 953 0 0 0 0.35s
✅ YAML prettier 15 0 0 0 1.43s
✅ YAML v8r 15 0 0 5.15s
✅ YAML yamllint 15 0 0 0.7s

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 30, 2025
@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 71.64634% with 93 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop-strands@7c3f5ac). Learn more about missing BASE report.

Files with missing lines Patch % Lines
newrelic/hooks/mlmodel_strands.py 69.30% 67 Missing and 26 partials ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             develop-strands    #1563   +/-   ##
==================================================
  Coverage                   ?   81.67%           
==================================================
  Files                      ?      209           
  Lines                      ?    24274           
  Branches                   ?     3841           
==================================================
  Hits                       ?    19825           
  Misses                     ?     3156           
  Partials                   ?     1293           

☔ 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.

umaannamalai and others added 13 commits November 3, 2025 19:12
* Add strands to tox.ini

* Add mock models for strands testing

* Add simple test file to validate strands mocking
Co-authored-by: Tim Pansino <tpansino@newrelic.com>
* Add strands to tox.ini

* Add mock models for strands testing

* Add simple test file to validate strands mocking
Co-authored-by: Tim Pansino <tpansino@newrelic.com>
@mergify mergify bot removed the tests-failing Tests failing in CI. label Nov 4, 2025
@mergify mergify bot added tests-failing Tests failing in CI. and removed tests-failing Tests failing in CI. labels Nov 4, 2025
@umaannamalai umaannamalai marked this pull request as ready for review November 4, 2025 20:52
@umaannamalai umaannamalai requested a review from a team as a code owner November 4, 2025 20:52
@mergify mergify bot added the tests-failing Tests failing in CI. label Nov 7, 2025
Copy link
Contributor

@hmstepanek hmstepanek left a comment

Choose a reason for hiding this comment

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

Some minor comments but everything else looks good to me.

if not parent:
return wrapped(*args, **kwargs)
else:
parent = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Regardless of wether there is a wrapper or not shouldn't we still set the parent to the current trace if there is a current trace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea here was that the if we had an async wrapper, then the trace context management would happen directly in the wrapper (ex: https://github.com/newrelic/newrelic-python-agent/blob/main/newrelic/common/async_wrapper.py#L25). This has been the same approach we take for other trace types such as ExternalTraces and FunctionTraces

def _construct_base_tool_event_dict(strands_attrs, tool_results, transaction, linking_metadata):
try:
try:
tool_output = tool_results[-1]["content"][0] if tool_results else None
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if by combining these under the same try-catch we might be missing cases where there's an error but no content?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The inner try-except handles the case where there is no content accessible. The outer try-except was meant to handle any other errors that come up when trying to grab attribute data in the case that there was or wasn't content. If there wasn't content, we set safeguards and keep going without raising an error. So technically that would cover cases with and without content?

@hmstepanek hmstepanek merged commit e3b9106 into develop-strands Nov 13, 2025
51 of 61 checks passed
@hmstepanek hmstepanek deleted the feat-strands-agents branch November 13, 2025 22:54
@mergify mergify bot removed the tests-failing Tests failing in CI. label Nov 13, 2025
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.

5 participants