Skip to content

Python: Capture workflow telemetry input and output - #7565

Open
slcnx wants to merge 2 commits into
microsoft:mainfrom
slcnx:fix/python-workflow-telemetry-io
Open

Python: Capture workflow telemetry input and output#7565
slcnx wants to merge 2 commits into
microsoft:mainfrom
slcnx:fix/python-workflow-telemetry-io

Conversation

@slcnx

@slcnx slcnx commented Aug 7, 2026

Copy link
Copy Markdown

Motivation & Context

Python workflow spans currently expose structural metadata but omit the payloads processed by executors and sent between them. This prevents OpenTelemetry backends from showing useful workflow inputs and outputs.

This change closes the Python payload-capture gap identified in #3075, follows the sensitive-data behavior introduced for .NET in #3467, and adds vendor-neutral OpenInference attributes so compatible backends can render workflow I/O directly.

Description & Review Guide

  • What are the major changes?
    • Capture serialized input/output on executor processing spans and serialized content on message send spans when sensitive telemetry is enabled.
    • Add source and target executor routing metadata to message send spans.
    • Populate OpenInference input/output value and MIME type attributes on workflow, executor, and message spans.
    • Reuse the framework JSON-safe conversion path and fall back to a type-only placeholder if telemetry serialization fails.
    • Add focused tests for enabled, disabled, structured-output, routing, and serialization-failure behavior.
  • What is the impact of these changes?
    • Payload capture remains disabled by default and adds no workflow-output accumulation when sensitive telemetry is disabled.
    • When explicitly enabled, workflow traces contain inspectable inputs and outputs at workflow, executor, and message granularity.
    • Existing workflow behavior and existing telemetry attributes remain unchanged.
  • What do you want reviewers to focus on?
    • Whether emitting both .NET-parity attributes and OpenInference attributes is the desired interoperability contract for Python workflow spans.
    • Whether workflow-level output should remain limited to explicit output events, as implemented here.

Related Issue

Fixes #3075

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add [BREAKING] to the title prefix, before or after any language prefix) - a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings August 7, 2026 07:57
@slcnx
slcnx temporarily deployed to github-app-auth August 7, 2026 07:57 — with GitHub Actions Inactive
@slcnx
slcnx temporarily deployed to github-app-auth August 7, 2026 07:57 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 7, 2026
@slcnx
slcnx temporarily deployed to github-app-auth August 7, 2026 07:58 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds opt-in workflow payload telemetry for improved OpenTelemetry/OpenInference observability.

Changes:

  • Captures workflow, executor, and message payloads when sensitive telemetry is enabled.
  • Adds message routing and OpenInference attributes.
  • Tests enabled, disabled, routing, structured-output, and serialization-failure behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/packages/core/agent_framework/observability.py Adds payload attributes and serialization helpers.
python/packages/core/agent_framework/_workflows/_workflow.py Captures workflow input and explicit outputs.
python/packages/core/agent_framework/_workflows/_workflow_context.py Captures sent-message content and routing.
python/packages/core/agent_framework/_workflows/_executor.py Captures executor input and output.
python/packages/core/tests/workflow/test_workflow_observability.py Adds focused telemetry tests.

Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
Comment thread python/packages/core/agent_framework/observability.py Outdated
@slcnx
slcnx marked this pull request as ready for review August 7, 2026 08:17
@slcnx
slcnx temporarily deployed to github-app-auth August 7, 2026 08:25 — with GitHub Actions Inactive
@slcnx

slcnx commented Aug 7, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree [company="yikaobang"]

@slcnx

slcnx commented Aug 7, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="yikaobang"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Workflow Middleware to Support Customizing Telemetry

2 participants