Skip to content

Python: [BREAKING] Keep Foundry approval state native - #10291

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 4 commits into
microsoft:python-foundry-hosting-rcfrom
eavanvalkenburg:foundry-hosting-follow-ups
Nov 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 4 commits into
microsoft:python-foundry-hosting-rcfrom
eavanvalkenburg:foundry-hosting-follow-ups

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation & Context

Responses hosting maintained a separate approval backend even though native agents already track pending approvals in AgentSession. This duplicated ownership and required an independent approval-store configuration. This follow-up uses the native agent/session authority and removes that redundant surface.

This PR targets python-foundry-hosting-rc, on top of #10260. It also documents workflow tool construction and folds the remaining storage adapters into _shared.py, as agreed during the implementation review.

Description & Review Guide

  • What are the major changes? Delegate approval binding, pending state, policy, consumption, and execution to existing Core agent/session behavior. Persist the whole native session before publishing a resumable approval. Keep only SDK wire-ID/native-ID/session-ID correlation in internal response-item metadata, not another approval store. Preserve exact checkpoint-owned authority for native workflows. Move the six remaining storage classes and four helpers into _shared.py without changing their implementations, and remove _state_store.py. Document factory-local tool construction and developer ownership of captured state; the workflow ownership guard is unchanged.
  • What is the impact of these changes? Remove function_approval_store_provider, FunctionApprovalStore, FoundryFunctionApprovalStore, and FunctionApprovalStoreProvider, including the optional agent_framework.foundry exports. Existing session-store customization remains supported. Public session/checkpoint storage imports are unchanged by the module consolidation. Old separate approval records are not migrated: applications must start fresh conversations rather than resume pending approvals from the old format.
  • What do you want reviewers to focus on? Native request-generation identity, session isolation, persistence-before-publication ordering, and balanced model-bound call/result history with capped transport history and staged approval batches. Transport metadata must never become approval authority. Exact stored-item lookup uses the SDK context's existing scoped provider because the SDK exposes no public exact-item lookup; the integration and its minimum-version behavior are documented and exercised.

For an existing agent or agent factory, the default migration is:

Before:

from agent_framework_foundry_hosting import FunctionApprovalStoreProvider, ResponsesHostServer

server = ResponsesHostServer(
    agent=agent,
    function_approval_store_provider=FunctionApprovalStoreProvider(),
)

After:

from agent_framework_foundry_hosting import ResponsesHostServer

server = ResponsesHostServer(agent=agent)

Applications with custom persistence must persist the complete AgentSession through agent_session_store_provider, rather than supply a separate approval provider.

Regular-agent history-source choices remain supported. Stored approval continuations use previous_response_id or a named conversation to restore the native session; an approval ID alone is not authority. Streaming and non-streaming output use the same persistence boundary. The store=false no-host-persistence contract is unchanged. Native workflows retain their existing checkpoint and complete-reply-batch contract; Invocations storage behavior is unchanged.

The maintainer-approved scope preserves existing Core session-level guarantees. It does not add durable single-consumption across independent workers or old session snapshots, and it does not implement #9537's pre-header HTTP 400 requirement. Those remain follow-up work rather than a new hosting-specific approval manager or private SDK preflight hook.

Local validation:

  • uv run --directory python --no-sync poe check -P foundry_hosting passed: 1,261 unit tests, Ruff, strict source typing, and all five test type checkers.
  • uv run --directory python --no-sync poe test -P core passed: 9,649 passed, 23 skipped, and 2 expected failures.
  • uv run --directory python --no-sync poe typing -P core passed.
  • uv run --directory python --no-sync python -m pytest -q -c packages/core/pyproject.toml packages/core/tests/core/test_foundry_namespace.py --no-cov --tb=short passed.
  • uv run --directory python --no-sync poe check -P core stops at two pre-existing line-length errors in agent_framework/security.py. That file is unchanged. The 36 external-service Foundry integration tests were not run.

Storage/import regressions and the new approval transport paths also passed with Responses SDK 2.2.0b1. All moved storage definitions retain identical ASTs. No dependency manifest or lockfile changed.

Related Issue

Partially addresses #10019, following the agreed native approval-ownership and breaking API direction. It remains open for the stronger durable-coordination requirements deliberately deferred from this PR.

Related to #10009 and #9537. This does not close #9537.

The only existing open PR referencing #10019 is the parent feature PR #10260. This is a follow-up into that feature branch, not a competing implementation.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Copilot assisted with the implementation, regression tests, documentation, storage-module consolidation, and this PR description.

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 links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • 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.

@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 breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible labels Nov 12, 2026

@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: Findings reported
Scope: full PR (1 commit(s)): 2a17c401fefc
Model: gpt-5.6-sol

Overview

The PR removes the separate approval store and shifts authority to AgentSession, with ETag conflict handling, exact wire/native/session correlation, persistence-before-publication, staged batches, and tests for native local approvals. Two supported paths remain broken: host-managed hosted MCP approvals lose their request context, and custom SupportsAgentRun approvals can be published without native pending authority.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 high) across 2 files. Details are attached to the affected lines below.

Affected areas: python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses_agent.py, python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses_shared.py

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

Result: Findings reported
Scope: 1 net-new commit(s): b92744207c04
Model: gpt-5.6-sol

Overview

This follow-up correctly makes native session state authoritative, defers approval publication until agent finalization, and adds exact pending-state validation plus broad history-mode coverage. However, the new hosted-request replay can bind an old same-session wire approval to a later request that reuses the native ID, and the finalization guard buffers all post-approval output without a limit. These leave one approval-confusion risk and one host-availability risk.

Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 2 files. Details are attached to the affected lines below.

Affected areas: python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses_agent.py, python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses_shared.py

@jpalvarezl Jose Alvarez (jpalvarezl) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Implementation-focused review.

@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) merged commit 02a4678 into microsoft:python-foundry-hosting-rc Nov 12, 2026
2 checks passed
Eduard van Valkenburg (eavanvalkenburg) added a commit that referenced this pull request Nov 12, 2026
* Python: [BREAKING] Keep Foundry approval state native

* Python: Fix native approval replay and publication

* Python: Harden Foundry approval continuations

* Python: Consolidate Foundry workflow state in shared

This branch was successfully deployed

1 active deployment
github-app-auth — 5a0d4c9a Deployed Nov 12, 2026 by eavanvalkenburg via add_label #27675
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants