Repository navigation
Python: redact exception telemetry when sensitive data is disabled - #9288
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Workflow failure events still expose exception messages and tracebacks when sensitive-data capture is disabled.
2 open findings
What changed in this PR
Redacts exception details from Python telemetry when sensitive-data capture is disabled while retaining error classification.
Changes:
- Gates exception events, status descriptions, workflow events, and logs.
- Preserves MCP error semantics.
- Adds regression coverage across tools, workflows, agents, and MCP.
| File | Description |
|---|---|
tests/workflow/test_workflow_observability.py |
Tests workflow error telemetry redaction. |
tests/workflow/test_edge.py |
Tests edge-span redaction. |
tests/core/test_tools.py |
Tests tool-span and log redaction. |
tests/core/test_observability.py |
Tests shared exception policy. |
tests/core/test_mcp_observability.py |
Tests MCP error telemetry. |
agent_framework/observability.py |
Centralizes sensitive exception capture. |
agent_framework/_workflows/_workflow.py |
Gates workflow span error messages. |
agent_framework/_workflows/_workflow_builder.py |
Gates build error details. |
agent_framework/_workflows/_functional.py |
Gates functional workflow span events. |
agent_framework/_tools.py |
Redacts function failure logs. |
agent_framework/_mcp.py |
Applies redaction across MCP operations. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Python Python / code-coverage/pythonThe overall line coverage in commit eba7bf6 in the Show a line coverage summary of the most impacted files.
Updated |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 8db7eb41ee90
Model: gpt-5.6-sol
Overview
The PR consistently routes ordinary tool, workflow, and MCP failures through sensitive-data gates, and its parameterized tests verify both redacted and detailed modes across the principal internal paths. Internal MCP handlers preserve low-cardinality error classification, but the exported MCP span helper drops all failure status for unhandled exceptions when redaction is active. The new workflow wrapper also broadens exception handling beyond OpenTelemetry's prior behavior and reports expected task cancellation as an error.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/observability.py
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
Found one remaining sensitive-data logging path.
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
The prior constructor leak is partially fixed, but remaining MCP failure logs still bypass the gate.
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
The reviewed connect/retry paths are fixed, but other raw MCP exception logs still bypass the new gate.
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
The sensitive-data boundary is now consistently applied across exception spans, workflow events, framework exception construction, and all exception-bearing MCP logs. Sensitive-off retains error type/status and stable operational diagnostics without messages or tracebacks; sensitive-on preserves detailed behavior. The follow-up regression coverage addresses the reviewed paths.
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
Re-reviewed the current head after the main merge and MCP task-abandonment follow-up. _MCPTaskAbandoned now uses the same sensitive-data-gated automatic logging policy, its failure paths retain caller-visible exception details without exporting them when sensitive data is disabled, and opt-in detailed logging remains compatible. The current net diff remains ready.

Motivation & Context
Production and regulated hosts commonly disable sensitive-data capture while retaining operational telemetry. Exception messages could still expose tool results, URLs, query strings, and other private values through span status descriptions, exception events, workflow events, MCP spans, and function failure logs even when sensitive-data capture was disabled.
This change makes the sensitive-data setting the consistent boundary for exception text while retaining low-cardinality failure diagnostics.
Description & Review Guide
error.typeandERRORstatus, but records exception events and message-bearing status descriptions only when sensitive-data capture is enabled. Explicit tool logs, workflow/build events, and MCP error descriptions follow the same policy. Workflow child spans no longer bypass the policy through OpenTelemetry's automatic exception capture, and MCP spans preserve semantic error types such astool_error.tool_errorsemantics.Related Issue
Fixes #9263
AI Assistance
AI assistance details: GitHub Copilot assisted with the implementation, regression tests, and PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.