Skip to content

Python: [BREAKING] Update functional workflow continuation handling - #7521

Open
moonbox3 wants to merge 7 commits into
microsoft:mainfrom
moonbox3:func-workflow-harden
Open

Python: [BREAKING] Update functional workflow continuation handling#7521
moonbox3 wants to merge 7 commits into
microsoft:mainfrom
moonbox3:func-workflow-harden

Conversation

@moonbox3

@moonbox3 moonbox3 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

Align functional workflow continuation behavior across pause, retry, and restore paths.

Description & Review Guide

  • What are the major changes? Refine continuation state transitions, checkpoint interactions, and related coverage.
  • What is the impact of these changes? Functional workflow continuation behavior is more explicit and consistent across direct and agent usage.
  • What do you want reviewers to focus on? State transitions and compatibility across continuation and checkpoint flows.

Related Issue

Internal tracking.

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]" in the title prefix, before or after a language prefix) — a workflow keeps the label and title prefix in sync automatically.

moonbox3 and others added 5 commits August 5, 2026 12:18
Use a versioned opaque single-use token on WorkflowRunResult, validate it before request correlation, consume it immediately before replayed user code, and rotate it on each pause. Carry the same explicit authority through streaming and non-streaming FunctionalWorkflowAgent responses.

Files changed: functional workflow/runtime result APIs, functional HITL regression tests, core agent guidance, and the functional HITL sample.

Next iteration: enforce pending-state overlap and token-authorized abandonment, then document and test checkpoint authorization boundaries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reject fresh messages and checkpoint restores while an in-memory continuation is pending. Add token-authorized abandonment on FunctionalWorkflow and FunctionalWorkflowAgent, and clear retained replay state atomically when authority is consumed while preserving the active message for token rotation and checkpoints.

Files changed: functional workflow runtime and agent adapter, functional lifecycle regression tests, and core workflow guidance.

Next iteration: preserve and document authorized checkpoint continuation boundaries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat checkpoint restore as a host- and storage-authorized path independent of process-local continuation tokens, and issue fresh authority whenever restored execution pauses again. Cover default and per-run storage, deterministic and custom request IDs, token rotation, and checkpoint-plus-response restore.

Files changed: functional workflow and checkpoint interface guidance, functional checkpoint lifecycle tests, the functional HITL sample, and core workflow guidance.

Next iteration: run the final repository-wide Python validation gates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run the complete Python workspace checks, aggregate coverage suite, repository hooks, and core package build from the final combined worktree. Keep the validation iteration code-neutral because all gates pass without corrective changes.

Files changed: none; this commit records the final validation gate.

Blockers: none. Next iteration: no remaining AFK tasks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Publish retained continuation state only after checkpoint persistence succeeds, and cover reuse after a transient save failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a8f47743-1cdc-4924-8e1b-667d0d790b78
Copilot AI lite review requested due to automatic review settings August 5, 2026 04:49
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 5, 2026 04:49 — with GitHub Actions Inactive
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 5, 2026 04:49 — with GitHub Actions Inactive
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 5, 2026 04:49 — with GitHub Actions Inactive
@moonbox3 moonbox3 added the breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible label Aug 5, 2026
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Aug 5, 2026
@moonbox3 moonbox3 added workflows Usage: [Issues, PRs], Target: Workflows and removed documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Aug 5, 2026
@moonbox3 moonbox3 self-assigned this Aug 5, 2026
@moonbox3
moonbox3 marked this pull request as ready for review August 5, 2026 04:50
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 5, 2026 04:50 — with GitHub Actions Inactive
Comment thread python/samples/03-workflows/functional/hitl_review.py Outdated
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _checkpoint.py158199%315
   _functional.py5753494%413–414, 480, 503, 512–514, 517, 547, 752–753, 760, 977, 1058, 1093, 1096–1097, 1105–1110, 1202–1203, 1209, 1326, 1356, 1685–1686, 1688, 1697, 1725, 1750
   _workflow.py3632593%61, 63, 68, 92, 97, 169, 205, 424–426, 428–429, 453, 487, 615, 654, 945, 966, 1014, 1026, 1032, 1037, 1063–1065
TOTAL44754410790% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9155 34 💤 0 ❌ 0 🔥 2m 1s ⏱️

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

This PR updates the Python functional workflow “HITL” (human-in-the-loop) continuation model so that response-only resumes require an explicit, single-use continuation token, aligning behavior across pause, retry, and checkpoint-restore flows.

Changes:

  • Introduces and plumbs an opaque continuation_token through functional workflow results and the functional workflow agent surface to authorize response-only in-memory resumes.
  • Tightens functional workflow state transitions by rejecting fresh input / checkpoint-restore while an in-memory continuation is pending, and adds explicit abandon_continuation(...) support.
  • Updates docs, samples, and test coverage to reflect the new continuation-token behavior (including streaming final responses carrying the token).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
python/samples/03-workflows/functional/hitl_review.py Updates the HITL sample to resume using the returned continuation token.
python/packages/core/tests/workflow/test_functional_workflow.py Adds/updates unit tests covering token-required resume, rejection paths, abandon behavior, and streaming token propagation.
python/packages/core/AGENTS.md Documents the new functional workflow continuation token semantics and constraints.
python/packages/core/agent_framework/_workflows/_workflow.py Extends WorkflowRunResult to carry an optional continuation_token.
python/packages/core/agent_framework/_workflows/_functional.py Implements functional continuation authority (issue/validate/consume), state clearing, abandon support, and agent propagation.
python/packages/core/agent_framework/_workflows/_checkpoint.py Clarifies that checkpoint IDs are locators, not authorization credentials.

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

Automated Code Review

Reviewers: 2 | Confidence: 86%

✓ Correctness

Found one cancellation-path correctness issue that can permanently lock the workflow after consuming its continuation token.

✓ Test Coverage

No actionable test-coverage gaps identified in the provided diff.


Automated review by moonbox3's agents

Comment thread python/packages/core/agent_framework/_workflows/_functional.py
Add owner recovery for lost tokens, harden malformed token validation, preserve consistent failure surfaces, and keep agent pending state aligned with resumable workflow state.

Document process-local single-use continuation semantics and extend regression coverage across direct, streaming, checkpoint, and agent paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a8f47743-1cdc-4924-8e1b-667d0d790b78
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 5, 2026 05:44 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Aug 5, 2026
Release the workflow run guard when cancellation interrupts resumed user code while keeping the single-use continuation token consumed.

Replace sample assertions with explicit runtime checks and add cancellation regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a8f47743-1cdc-4924-8e1b-667d0d790b78
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 5, 2026 06:10 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python workflows Usage: [Issues, PRs], Target: Workflows

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants