Add OutputScope for output message tracing with parent span linking#164
Draft
Add OutputScope for output message tracing with parent span linking#164
Conversation
- Add Response model class for agent execution response details - Add spans_scopes directory with OutputScope implementation - Add unit tests for OutputScope functionality Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Extract changes to output span from existing PR
Add OutputScope for output message tracing
Feb 6, 2026
Similar to the .NET ExecuteToolScope, the OutputScope now accepts an optional parent_id parameter to link spans to upstream operations. Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot
AI
changed the title
Add OutputScope for output message tracing
Add OutputScope with parent_id for output message tracing
Feb 6, 2026
Similar to the .NET implementation, the base OpenTelemetryScope class now accepts an optional parent_id parameter that sets the CUSTOM_PARENT_SPAN_ID_KEY attribute on the span. This allows all scope subclasses to support parent span linking consistently. Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot
AI
changed the title
Add OutputScope with parent_id for output message tracing
Add OutputScope with parent_id support on base OpenTelemetryScope
Feb 6, 2026
Changed the behavior of record_output_messages to append new messages to the accumulated list rather than replacing all messages. This allows collecting output messages over multiple calls during the scope's lifetime. Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot
AI
changed the title
Add OutputScope with parent_id support on base OpenTelemetryScope
Add OutputScope for output message tracing with parent_id support
Feb 6, 2026
Changed the parent_id implementation to properly link spans by parsing the W3C Trace Context format parent ID and using it to create a proper span context. This aligns with the .NET implementation which calls `activity?.SetParentId(parentId!)`. Added validation for W3C Trace Context version and trace_id/span_id lengths. Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot
AI
changed the title
Add OutputScope for output message tracing with parent_id support
Add OutputScope for output message tracing with proper parent span linking
Feb 6, 2026
Copilot
AI
changed the title
Add OutputScope for output message tracing with proper parent span linking
Add OutputScope for output message tracing with parent span linking
Feb 6, 2026
Refactored W3C Trace Context parsing: - Added W3C Trace Context validation constants - Added validate_w3c_trace_context_version() helper - Added validate_trace_id() helper with hex validation - Added validate_span_id() helper with hex validation - Moved parse_parent_id_to_context() from opentelemetry_scope.py Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot
AI
changed the title
Add OutputScope for output message tracing with parent span linking
Add OutputScope for output message tracing with W3C parent span linking
Feb 6, 2026
…similar ones Reduced from 10 tests to 4 focused tests: - test_output_scope_creates_span_with_messages (merged span name and messages tests) - test_record_output_messages_appends (merged multiple append tests) - test_output_scope_with_parent_id (parent linking) - test_output_scope_dispose (manual dispose) All tests use real spans via InMemorySpanExporter (no mocks). Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot
AI
changed the title
Add OutputScope for output message tracing with W3C parent span linking
Add OutputScope for output message tracing with parent span linking
Feb 6, 2026
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.
Extracts output span functionality from PR #113. Adds
OutputScopefor tracing agent output messages with W3C Trace Context parent span linking.New files
spans_scopes/output_scope.py- OpenTelemetry scope for output messagesmodels/response.py-ResponsedataclassBase scope changes
parent_idparameter toOpenTelemetryScope.__init__Utils refactoring
parse_parent_id_to_context()moved toutils.pyvalidate_trace_id(),validate_span_id()with hex validationBehavior
record_output_messages()appends to accumulated list (not replace)Tests
Reduced from 10 to 4 focused tests using real spans via
InMemorySpanExporter.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
il-1234567812345678123456781234567.8.tenant.api.powerplatform.com/home/REDACTED/work/Agent365-python/Agent365-python/.venv/bin/pytest pytest tests/observability/core/ -v --tb=short -m not integration(dns block)il-testtenan.t.tenant.api.powerplatform.com/home/REDACTED/work/Agent365-python/Agent365-python/.venv/bin/pytest pytest tests/observability/core/ -v --tb=short -m not integration(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.