Add first-class agent identity tracking (OTel GenAI semantic conventions)#3
Open
prathamesh-sonpatki wants to merge 3 commits intomainfrom
Open
Add first-class agent identity tracking (OTel GenAI semantic conventions)#3prathamesh-sonpatki wants to merge 3 commits intomainfrom
prathamesh-sonpatki wants to merge 3 commits intomainfrom
Conversation
…ventions Add gen_ai.agent.id, gen_ai.agent.name, gen_ai.agent.description, and gen_ai.agent.version attributes following the OpenTelemetry GenAI semantic conventions for agent spans. This enables tracking agent identity across multi-agent systems with automatic context propagation. - Add agent_context() context manager (same pattern as conversation_context) - Auto-propagate agent attributes via Last9SpanProcessor - Add create_agent/invoke_agent operation names - Add agent_tracking.py example - Update README and context_tracking example Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 new tests covering: - Basic agent_id propagation to spans - All fields (id, name, version) - Nested span propagation - Context cleanup after exit - Inner context overrides outer - Sequential multi-agent (routing pattern) - Nesting with conversation_context - Nesting with workflow_context - Triple nesting (conversation + agent + workflow) - Multi-agent handoff within same conversation - No-span edge case Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agent_context()context manager for tracking agent identity using OTel GenAI semantic conventions (gen_ai.agent.id,gen_ai.agent.name,gen_ai.agent.description,gen_ai.agent.version)Last9SpanProcessorcreate_agent/invoke_agentoperation names per the OTel specWhy
The OpenTelemetry GenAI SIG defines first-class agent attributes (experimental). Major frameworks (OpenAI Agents SDK, CrewAI, AutoGen) already emit these. This aligns the SDK with the emerging standard so spans are natively understood by any OTel-compatible backend.
Usage
Changes
last9_genai/core.pyGenAIAttributes.AGENT_*constants,Operations.CREATE_AGENT/INVOKE_AGENTlast9_genai/context.pyagent_context()context manager + contextvarslast9_genai/processor.pyon_start()last9_genai/__init__.pyagent_contextREADME.mdexamples/agent_tracking.pyexamples/context_tracking.pyTest plan
agent_contextpropagatesgen_ai.agent.idto child spansconversation_contextandworkflow_contextexamples/agent_tracking.pyend-to-end🤖 Generated with Claude Code