Skip to content

Python: add option to disable return-to-previous handoff routing - #8639

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
eavanvalkenburg:restore-handoff-routing-option
Sep 23, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
eavanvalkenburg:restore-handoff-routing-option

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation & Context

The handoff refactor made user replies always return to the agent that requested them. Workflows that use the start
agent to re-evaluate each user turn no longer have a way to opt out of that routing behavior.

This restores a configuration option while preserving the current default.

Description & Review Guide

  • What are the major changes? Adds HandoffBuilder.enable_return_to_previous(enabled=True), routes replies through
    the configured start agent when disabled, and adds focused tests and documentation.
  • What is the impact of these changes? Existing workflows are unchanged by default. Callers can pass False to
    have the start agent reconsider each subsequent user response before handing off again.
  • What do you want reviewers to focus on? The broadcast/cache ordering used to keep every agent synchronized while
    activating the start agent only for the opt-out path.

Related Issue

Closes #3429

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 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.

Copilot review overview

🟡 Changes recommended

The test must verify that the reactivated start agent receives the user response before running.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds an opt-out from return-to-previous handoff routing, allowing the start agent to reconsider user responses.

Changes:

  • Adds enable_return_to_previous().
  • Routes responses through the start agent when disabled.
  • Adds documentation and routing tests.
File Description
_handoff.py Implements configurable response routing.
test_handoff.py Tests default and configured routing.
README.md Documents the new option.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): 6fecf1731ba3
Model: gpt-5.6-sol-fast

Overview

This PR preserves return-to-previous routing by default and adds an opt-out path that broadcasts the resumed user message before activating the configured start agent. The fully connected workflow topology, per-edge message ordering, start-agent validation, and focused routing tests guard the intended behavior. No Critical, High, or Medium defect remains after reconciliation.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Merged via the queue into microsoft:main with commit 7fb41d6 Sep 23, 2026
43 checks passed
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) deleted the restore-handoff-routing-option branch September 23, 2026 18:25

This branch was previously deployed

1 inactive deployment
github-app-auth — b0cd69da Deployed Sep 22, 2026 by eavanvalkenburg via add_label #23521
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: add option to disable return-to-previous in handoff

3 participants