fix(sdk): @agent decorator no longer overwrites enclosing @workflow name#4288
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn ChangesAGENT span workflow name conditional assignment
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if context_api.get_value("workflow_name") is None: | ||
| set_workflow_name(entity_name) |
There was a problem hiding this comment.
so if "workflow_name" is none we set entity_name as workflow name.
But if it's not None? It's never set?
| if tlp_span_kind == TraceloopSpanKindValues.AGENT: | ||
| elif tlp_span_kind == TraceloopSpanKindValues.AGENT: | ||
| set_agent_name(entity_name) | ||
| if context_api.get_value("workflow_name") is None: |
There was a problem hiding this comment.
const it please no magic strings
The @agent decorator unconditionally called set_workflow_name(entity_name),
clobbering the workflow_name attached to the OTel context by an enclosing
@workflow. Child LLM spans then read the agent name as their workflow name,
making (agent_name, workflow_name) groupings collapse: the same agent
running under two different workflows became indistinguishable.
Now @agent only sets workflow_name when one is not already in context,
preserving fallback behavior for bare @agent (no enclosing @workflow) while
fixing the nested case.
Summary by CodeRabbit