Repository navigation
Python: [BREAKING] Keep Foundry approval state native - #10291
Conversation
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
Implementation-focused review.
02a4678
into
microsoft:python-foundry-hosting-rc
* 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
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
_shared.pywithout 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.function_approval_store_provider,FunctionApprovalStore,FoundryFunctionApprovalStore, andFunctionApprovalStoreProvider, including the optionalagent_framework.foundryexports. 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.For an existing agent or agent factory, the default migration is:
Before:
After:
Applications with custom persistence must persist the complete
AgentSessionthroughagent_session_store_provider, rather than supply a separate approval provider.Regular-agent history-source choices remain supported. Stored approval continuations use
previous_response_idor 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. Thestore=falseno-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_hostingpassed: 1,261 unit tests, Ruff, strict source typing, and all five test type checkers.uv run --directory python --no-sync poe test -P corepassed: 9,649 passed, 23 skipped, and 2 expected failures.uv run --directory python --no-sync poe typing -P corepassed.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=shortpassed.uv run --directory python --no-sync poe check -P corestops at two pre-existing line-length errors inagent_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
AI assistance details: Copilot assisted with the implementation, regression tests, documentation, storage-module consolidation, and this PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.