Skip to content

Conversation

@sgoel-nr
Copy link

@sgoel-nr sgoel-nr commented Nov 14, 2025

Summary

This PR addresses several bugs related to LangChain integration in the New Relic Python Agent, specifically focusing on message timestamp handling and role assignments for chat completion events.

Changes

Message Timestamp Handling

  • Fixed request message timestamp preservation for LangChain chat completion messages
  • Ensured proper timestamp propagation to LlmChatCompletionMessage events
  • Corrected request timestamp handling for LlmChatCompletionSummary table entries

Role Assignment

  • Implemented default role assignment for input/output messages within LangChain
  • Ensures consistent role metadata across chat completion events

Bedrock Integration

  • Bedrock methods are properly integrated with the LangChain instrumentation

@sgoel-nr sgoel-nr requested a review from a team as a code owner November 14, 2025 06:08
@CLAassistant
Copy link

CLAassistant commented Nov 14, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ bonczj
✅ sgoel-nr
❌ mergify[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

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

codecov-commenter commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 77.35849% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.28%. Comparing base (8d18c0a) to head (43cb0b4).

Files with missing lines Patch % Lines
newrelic/hooks/external_botocore.py 66.66% 9 Missing ⚠️
newrelic/hooks/mlmodel_langchain.py 71.42% 0 Missing and 2 partials ⚠️
newrelic/hooks/mlmodel_gemini.py 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1580      +/-   ##
==========================================
- Coverage   81.82%   81.28%   -0.54%     
==========================================
  Files         207      207              
  Lines       23953    23979      +26     
  Branches     3799     3804       +5     
==========================================
- Hits        19599    19491     -108     
- Misses       3086     3231     +145     
+ Partials     1268     1257      -11     

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

@sgoel-nr sgoel-nr changed the title Sgoel/langchain bug fix LangChain: Fix message timestamps, add default role assignment, and Bedrock support Nov 14, 2025
@mergify mergify bot added the merge-conflicts Merge conflicts detected. label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflicts Merge conflicts detected. tests-failing Tests failing in CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants