Skip to content

Python: Align AG-UI workflow cache scoping - #7277

Merged
moonbox3 merged 2 commits into
microsoft:mainfrom
moonbox3:ag-ui-workflow-scope-isolation
Jul 23, 2026
Merged

Python: Align AG-UI workflow cache scoping#7277
moonbox3 merged 2 commits into
microsoft:mainfrom
moonbox3:ag-ui-workflow-scope-isolation

Conversation

@moonbox3

Copy link
Copy Markdown
Contributor

Motivation & Context

Keep workflow-factory instance selection aligned with configured Snapshot Scope.

Description & Review Guide

  • What are the major changes? Apply the resolved scope to the in-memory workflow cache without requiring snapshot persistence.
  • What is the impact of these changes? Configured scopes partition live workflow instances; defaults are unchanged.
  • What do you want reviewers to focus on? Scope propagation and cache reuse coverage.

Related Issue

N/A

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 a language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI review requested due to automatic review settings July 23, 2026 06:00
@moonbox3
moonbox3 temporarily deployed to github-app-auth July 23, 2026 06:00 — with GitHub Actions Inactive
@moonbox3
moonbox3 temporarily deployed to github-app-auth July 23, 2026 06:00 — with GitHub Actions Inactive
@moonbox3
moonbox3 temporarily deployed to github-app-auth July 23, 2026 06:00 — 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 Jul 23, 2026

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 aligns AG-UI workflow-factory instance caching with the configured Snapshot Scope by propagating the resolved scope into workflow runs even when snapshot persistence is not configured. This ensures that multi-tenant/multi-user deployments don’t accidentally share live in-memory Workflow instances when threadId collides across scopes.

Changes:

  • Always pass the resolved Snapshot Scope into the run payload when snapshot_scope_resolver is provided, even without a snapshot store, so AgentFrameworkWorkflow(workflow_factory=...) caches are correctly partitioned.
  • Add a regression test validating scope-partitioned workflow-factory caching without snapshot persistence.
  • Update docs/comments to clarify that Snapshot Scope is the authorization/cache boundary for both snapshots and live workflow instances.

Reviewed changes

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

File Description
python/packages/ag-ui/agent_framework_ag_ui/_endpoint.py Propagates resolved snapshot scope into input_data whenever a resolver is provided, enabling scoped workflow caching without snapshot persistence.
python/packages/ag-ui/agent_framework_ag_ui/_workflow.py Clarifies that Snapshot Scope is the boundary for both snapshots and in-memory workflow-factory instances.
python/packages/ag-ui/tests/ag_ui/test_endpoint.py Adds coverage ensuring workflow-factory instances are cached per resolved scope even with no snapshot store.
python/packages/ag-ui/README.md Documents that snapshot_scope_resolver also scopes the in-memory workflow cache for workflow factories in multi-user deployments.

@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: 5 | Confidence: 92% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by moonbox3's agents

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _endpoint.py119496%63, 198, 230–231
   _workflow.py2041692%64, 127, 132, 171, 210–211, 294, 337, 339, 341–343, 345, 363–365
TOTAL45257445190% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9369 33 💤 0 ❌ 0 🔥 2m 35s ⏱️

@moonbox3
moonbox3 marked this pull request as ready for review July 23, 2026 06:11
@moonbox3
moonbox3 temporarily deployed to github-app-auth July 23, 2026 06:12 — with GitHub Actions Inactive

@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: 5 | Confidence: 92% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by moonbox3's agents

@moonbox3
moonbox3 temporarily deployed to github-app-auth July 23, 2026 06:19 — with GitHub Actions Inactive
@moonbox3
moonbox3 enabled auto-merge July 23, 2026 09:46
@moonbox3
moonbox3 added this pull request to the merge queue Jul 23, 2026
Merged via the queue into microsoft:main with commit cd6345e Jul 23, 2026
38 checks passed
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.

4 participants