Skip to content

Comments

Python: Add missing system instruction attr to invoke_agent span#4012

Merged
TaoChenOSU merged 4 commits intomicrosoft:mainfrom
TaoChenOSU:taochen/python-add-missing-system-instruction-to-agent-invoke-span
Feb 17, 2026
Merged

Python: Add missing system instruction attr to invoke_agent span#4012
TaoChenOSU merged 4 commits intomicrosoft:mainfrom
TaoChenOSU:taochen/python-add-missing-system-instruction-to-agent-invoke-span

Conversation

@TaoChenOSU
Copy link
Contributor

@TaoChenOSU TaoChenOSU commented Feb 17, 2026

Motivation and Context

The system instruction attribute is silently dropped from the agent_invoke span, because we are using the wrong dictionary.

Description

Fix the bug by using the correct dictionary.

Previously:
image

After:
image

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@TaoChenOSU TaoChenOSU self-assigned this Feb 17, 2026
Copilot AI review requested due to automatic review settings February 17, 2026 19:46
@TaoChenOSU TaoChenOSU added python observability Issues related to observability or telemetry labels Feb 17, 2026
@github-actions github-actions bot changed the title Add missing system instruction attr to invoke_agent span Python: Add missing system instruction attr to invoke_agent span Feb 17, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 17, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/anthropic/agent_framework_anthropic
   _chat_client.py3723590%453, 540, 542, 666–667, 730, 751–752, 795–797, 799, 812–813, 820–822, 826–828, 832–835, 947, 957, 991, 1013, 1153–1154, 1171, 1184, 1197, 1222–1223
packages/core/agent_framework
   observability.py6178087%346, 348–350, 353–355, 360–361, 367–368, 374–375, 382, 384–386, 389–391, 396–397, 403–404, 410–411, 418, 687, 690, 698–699, 702–705, 707, 710–712, 715–716, 744, 746, 757–759, 761–763, 767, 775, 876, 878, 1027, 1029, 1033–1038, 1040, 1043–1047, 1049, 1158–1159, 1161, 1218–1219, 1354, 1524, 1527, 1586, 1756, 1910, 1912
TOTAL20606311584% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4013 225 💤 0 ❌ 0 🔥 1m 9s ⏱️

@TaoChenOSU TaoChenOSU enabled auto-merge February 17, 2026 20:42
@TaoChenOSU TaoChenOSU added this pull request to the merge queue Feb 17, 2026
Merged via the queue into microsoft:main with commit 9a369c6 Feb 17, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

observability Issues related to observability or telemetry python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants