Python: Add missing system instruction attr to invoke_agent span#4012
Merged
TaoChenOSU merged 4 commits intomicrosoft:mainfrom Feb 17, 2026
Conversation
invoke_agent spaninvoke_agent span
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the observability instrumentation where system instructions from default_options were being silently dropped from the agent_invoke span. The fix corrects the code to use merged_options (which contains both default_options and runtime options) instead of options (which contains only runtime options) when extracting system instructions for telemetry.
Changes:
- Fixed system instruction extraction in telemetry to use merged options instead of runtime options only
- Added comprehensive test coverage for instruction merging scenarios in both streaming and non-streaming modes
- Updated observability sample to enable sensitive data to demonstrate the fix
- Added azure-ai-search to enforced coverage modules (housekeeping)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/observability.py | Fixed two calls to _get_instructions_from_options to use merged_options instead of options |
| python/packages/core/tests/core/test_observability.py | Added comprehensive test coverage for instructions from default_options, runtime options, merged options, streaming modes, and edge cases |
| python/samples/02-agents/observability/agent_observability.py | Enabled sensitive data in observability configuration and improved comment formatting |
| .github/workflows/python-check-coverage.py | Added azure-ai-search to enforced coverage modules |
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||
eavanvalkenburg
approved these changes
Feb 17, 2026
giles17
approved these changes
Feb 17, 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.
Motivation and Context
The system instruction attribute is silently dropped from the
agent_invokespan, because we are using the wrong dictionary.Description
Fix the bug by using the correct dictionary.
Previously:

After:

Contribution Checklist