Genai utils | Add AgentInvocation type#4274
Open
etserend wants to merge 6 commits intoopen-telemetry:mainfrom
Open
Genai utils | Add AgentInvocation type#4274etserend wants to merge 6 commits intoopen-telemetry:mainfrom
etserend wants to merge 6 commits intoopen-telemetry:mainfrom
Conversation
1b5cd9f to
08e2b07
Compare
Author
|
Sample trace from [demo app](Trace: b6db19ce1c2846667d1b237c4e264a0a Trace: b6db19ce1c2846667d1b237c4e264a0a |
keith-decker
reviewed
Mar 3, 2026
| response_id: str | None = None | ||
| finish_reasons: list[str] | None = None | ||
| input_tokens: int | None = None | ||
| output_tokens: int | None = None |
Contributor
There was a problem hiding this comment.
I'm starting to see a lot of duplicated properties on types. Wondering if we can consolidate some of these into reusable bits.
Comment on lines
+432
to
+444
| # System instructions (Opt-In) | ||
| if ( | ||
| is_experimental_mode() | ||
| and get_content_capturing_mode() | ||
| in ( | ||
| ContentCapturingMode.SPAN_ONLY, | ||
| ContentCapturingMode.SPAN_AND_EVENT, | ||
| ) | ||
| and creation.system_instruction | ||
| ): | ||
| attributes[GenAI.GEN_AI_SYSTEM_INSTRUCTIONS] = gen_ai_json_dumps( | ||
| [asdict(p) for p in creation.system_instruction] | ||
| ) |
Contributor
There was a problem hiding this comment.
This can probably be a helper to be used with agent/llm/tool invocations
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.
Description
This PR adds the
AgentInvocationtype extending_BaseAgentfor agent invocation (invoke_agent) spans. It providesTelemetryHandlerlifecycle methods and an agent() context manager — aligned with the GenAI agent span semantic conventions.Builds on the
_BaseAgentbase class and AgentCreation type added in #4217. Agent metrics and events to come in follow-up PRs.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.