Skip to content

Python: Preserve termination results in Agent and Chat middleware - #9681

Open
ssccinng wants to merge 1 commit into
microsoft:mainfrom
ssccinng:openfix/067a12af-712e-47fe-95df-38ee7945a243
Open

ssccinng wants to merge 1 commit into
microsoft:mainfrom
ssccinng:openfix/067a12af-712e-47fe-95df-38ee7945a243

Conversation

@ssccinng

Copy link
Copy Markdown
Contributor

Motivation & Context

Agent and Chat middleware discarded MiddlewareTermination.result, returning None when context.result was unset.

Description & Review Guide

Both pipelines now use the exception result only when context.result is None. Existing context results retain precedence, and returned streams receive registered transforms and result hooks.

Regression coverage includes all eight combinations of middleware type, streaming mode, and pipeline or Agent.run execution, plus result precedence and stream hooks. Stream assertions respect the finalizer's aggregation of original updates. Test execution is pending.

Related Issue

N/A - localized bug fix.

AI Assistance

Implementation and regression tests were AI-assisted.

Contribution Checklist

  • All unit tests pass.
  • Regression tests added.
  • This is not a breaking change.

Validation

The configured baseline checks passed before the change.

The regression test fails against the original code and passes after the fix.

  • cd python/packages/core && python -m pytest -q -m 'not integration' tests/core/test_middleware_context_result.py tests/core/test_middleware_with_agent.py tests/core/test_middleware_with_chat.py tests/core/test_middleware.py: passed.

  • cd 'python/packages/core' && python -m pytest -q -m 'not integration' 'tests/core/test_middleware_context_result.py' 'tests/core/test_middleware_with_agent.py' 'tests/core/test_middleware_with_chat.py': passed.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 25, 2026
@github-actions github-actions Bot changed the title Preserve termination results in Agent and Chat middleware Python: Preserve termination results in Agent and Chat middleware Oct 25, 2026

This branch was previously deployed

1 inactive deployment
github-app-auth — 80ba171b Deployed Oct 25, 2026 by ssccinng via team_check #7414
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.

1 participant