ref!: Stop disabling client integrations when an agent integration is present - #7493
Conversation
Codecov Results 📊✅ 66703 passed | ⏭️ 3050 skipped | Total: 69753 | Pass Rate: 95.63% | Execution Time: 190m 41s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 87.76%. Project has 2262 uncovered lines. Files with missing lines (4)
Coverage diff@@ Coverage Diff @@
## master #PR +/-##
==========================================
- Coverage 90.17% 89.46% -0.71%
==========================================
Files 193 180 -13
Lines 25768 21460 -4308
Branches 9532 7804 -1728
==========================================
+ Hits 23236 19198 -4038
- Misses 2532 2262 -270
- Partials 1432 1217 -215Generated by Codecov Action |
sentrivana
left a comment
There was a problem hiding this comment.
I guess this would work.
Why do we want to go via this route in the first place? What do we gain over the current way of doing things?
| @property | ||
| def span(self) -> "StreamedSpan": | ||
| return self._span |
There was a problem hiding this comment.
Why have a special property for this and not return the span directly in __enter__? Might be wrong, but from a cursory look we seem to only ever be interacting with the span when using the context manager.
There was a problem hiding this comment.
The idea would be for the agent frameworks to use this wrapper with the context manager protocol since __exit__() sets
self._span._scope._agent_framework_generation_entered = False|
Users that use both agent and client frameworks in the same process would benefit. |
Description
Use a boolean scope member to suppress chat spans from client libraries that are inside a chat span from an agent framework. Add the
traces._AgentFrameworkChatGenerationContextwrapper to ensure the scope member is cleaned up correctly when the agent framework span exits.Remove logic that disables client library integrations when an agent library is active. Delete the
integration_deactivationtox environment that ran the corresponding tests.Use the context manager in all agent frameworks that create chat generation spans (
langchain,pydantic-ai, andopenai-agents). Add early returns for chat generation spans in theopenai,anthropic, andgoogle-genaiclient libraries to prevent duplicate generation spans.Remove embedding patches from the
langchainintegration. These must now be provided by client libraries likeopenai,anthropic, etc.Issues
Closes #5515
Reminders
uv run ruff.feat:,fix:,ref:,meta:)