Skip to content

Python: [BREAKING] Prepare Foundry Hosting for RC - #10260

Draft
Eduard van Valkenburg (eavanvalkenburg) wants to merge 26 commits into
mainfrom
python-foundry-hosting-rc
Draft

Eduard van Valkenburg (eavanvalkenburg) wants to merge 26 commits into
mainfrom
python-foundry-hosting-rc

Conversation

@eavanvalkenburg

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 596f85121d3d8d0c0b047f5bd292e2c5c54c874b

Dimension Assessment Rationale
Change confidence 7/10 ↑ Follow-up fixes are merged into the RC branch and included in this PR.
↑ The integrated changes have issue-linked implementation coverage.
↓ Pre-commit, typing, and merge-gatekeeper checks currently fail on this PR.
Diagnosis confidence 9/10 ↑ The merged changes map to the reported store overhead, branching, file-bearing replies, and usage aggregation issues.
↓ No deployed Foundry environment was checked.
Evidence fit 8/10 ↑ The merged changes match the reported behavior for #8280, #8578, #10133, and #10189.
↓ #8418 and durable single-consumption in #10019 remain open; the #9537 pre-streaming HTTP 400 path needs an upstream SDK hook.

Motivation & Context

This PR integrates the coordinated breaking changes for Python Foundry Hosting from python-foundry-hosting-rc into main. It prepares a stable Responses surface in the single agent-framework-foundry-hosting package. Invocations and Toolbox stay experimental.

The API review in #10009 found a combined host, implicit configuration, a separate approval store, implicit forwarding of request options, and inconsistent terminology. The branch resolves these problems in focused PRs. Each PR was reviewed and merged into the feature branch.

Description & Review Guide

  • What are the major changes?

  • What is the impact of these changes? This is a breaking migration of constructors, imports and options, without aliases or a compatibility shim for the old names. Agent hosts reject WorkflowAgent. Workflow hosts reject built workflow instances and agents. Agent continuation is session-backed. Workflow continuation and pending authority are checkpoint-owned. Request fields reach the agent only through parse_input, so per-request model control is now an explicit opt-in. Old separate approval records are not migrated: pending approvals in the old format require a new conversation. Clients of Invocations must use JSON and framed SSE.

    Before:

    from agent_framework_foundry_hosting import HostedResponseRequest, ResponsesHostServer
    from azure.ai.agentserver.responses import ResponsesServerOptions
    
    def prepare_options(request: HostedResponseRequest, options: dict) -> dict:
        return {"temperature": options.get("temperature")}
    
    server = ResponsesHostServer(
        agent=agent,
        options=ResponsesServerOptions(default_fetch_history_count=100),
        prepare_options=prepare_options,
    )
    workflow_server = ResponsesHostServer(workflow=build_workflow, parse_response=parse_workflow_turn)

    After:

    from agent_framework_foundry_hosting import (
        ParsedHostedAgentRequest,
        ResponsesHostServer,
        ResponsesRequest,
        ResponsesWorkflowHostServer,
    )
    
    async def parse_input(request: ResponsesRequest) -> ParsedHostedAgentRequest:
        return ParsedHostedAgentRequest(
            messages=await request.get_input_messages(),
            options={"temperature": request.request.get("temperature")},
        )
    
    server = ResponsesHostServer(
        agent=agent,
        max_history_items=100,
        parse_input=parse_input,
        extra_fields="error",
    )
    workflow_server = ResponsesWorkflowHostServer(workflow=build_workflow, parse_input=parse_workflow_turn)

    The application supplies agent, build_workflow and parse_workflow_turn. Workflow factories must build fresh workflows, executors, agents, clients and mutable tools for each request. Workflow names and executor IDs must stay stable so that checkpoints can be restored. The package README contains the full migration guide.

  • What do you want reviewers to focus on? The public construction and migration surface, rejection of mismatched agents and workflows before dispatch, the parse_input and extra_fields boundary, persistence of the native session before an approval is published, the consent continuation, and streaming and non-streaming parity for continuation and background behavior. The follow-up PRs for workflow attachment replies, MCP approval batches, Toolbox citations and usage aggregation are now merged into the feature branch and included here. Remaining work includes the caller-field hardening tracked by Python: [Team][Action] Improve prepare_options documentation and examples #10021 and Python: [Team][Investigation] Review prepare_options and align options work #10023, plus the outstanding approval and SDK boundaries listed below.

Related Issue

Fixes #10010
Fixes #10012
Fixes #10013
Fixes #10014
Fixes #10015
Fixes #10018
Fixes #10020
Fixes #9903
Fixes #10336
Fixes #10346
Fixes #7250
Fixes #8280
Fixes #8578
Fixes #10133
Fixes #10189

Partially addresses #10019. Durable single consumption across workers is deferred under ADR 0055.

Relates to #10009, #7688 and #9530. This PR does not complete the broader investigations into workflow concurrency or cross-host continuation contracts.

This PR integrates the merged feature-branch PRs #10224, #10269, #10291, #10339, #10353, #10391, #10464, #10482, #10392, #10456 and #10551 into main. It is not a competing implementation. Each listed issue has explicit maintainer agreement, recorded in the issue or in its feature-branch PR. Remaining work before release includes #10017, #10021, #10022, #10023 and #8418, plus final lifecycle declarations and release qualification. #9537 is closed as not planned: the pre-streaming HTTP 400 path requires an upstream public SDK hook. The partial-batch handling change in #10482 does not provide that pre-header behavior.

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 implementation, tests, samples, migration documentation 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.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:13
@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 11, 2026
@github-code-quality

github-code-quality Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: Python

Python / code-coverage/python

main a519cb2 python-foundry-hosti... 596f851 +/-
92% 92% 0%
View coverage of the 10 most impacted files.
File main a519cb2 python-foundry-hosti... 596f851 +/-
packages/foundr...ing/_toolbox.py 99% 96% -3%
packages/core/a...flows/_agent.py 92% 89% -3%
packages/core/a...amework/_mcp.py 92% 92% 0%
packages/foundr...ponses_agent.py 0% 90% +90%
packages/foundr...ses_workflow.py 0% 90% +90%
packages/foundr...tions_shared.py 0% 90% +90%
packages/foundr...ting/_shared.py 0% 92% +92%
packages/foundr...onses_shared.py 0% 92% +92%
packages/foundr...ons_workflow.py 0% 93% +93%
packages/foundr...ations_agent.py 0% 95% +95%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated December 03, 2026 19:04 UTC

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.

🔵 Needs a closer look

Cleanup ownership is registered too late, allowing replay and pre-dispatch exits to leak constructor-created clients or credentials, with regression coverage needed for these paths.

No open issues 🎉

What changed in this PR

Integrates the breaking agent/native-workflow host split into Python Foundry Hosting as preparation for RC. Configuration, approval, consent, and final release qualification work remains outstanding.

Changes:

  • Separates agent and native workflow hosts, with request-aware factories and explicit workflow parsers.
  • Renames request/parser APIs and history/background source values; removes the constructor store= alias while preserving wire-level storage semantics.
  • Updates shared internals, public exports, regression tests, maintained samples, migration guidance, and proposed ADR 0055.
File Description
skills/​agent-framework-builder-python/​references/​hosting-and-deployment.md Documents separate hosts and request-owned workflow resources.
python/​scripts/​sample_validation/​skills/​foundry-hosted-agent-validation/​SKILL.md Recognizes native workflow host entry points.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​workflows/​README.md Documents the workflow host and required factory.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​workflows/​main.py Migrates typed workflows to the new host/parser APIs.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​workflows/​approval.py Migrates the approval workflow host and parser.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​tools/​README.md Updates history-source terminology.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​tools/​main.py Updates the factory signature and history source.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​steerable_long_running_agent/​verify_steering.py Makes the guard-check factory request-aware.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​steerable_long_running_agent/​README.md Updates history-source documentation.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​steerable_long_running_agent/​main.py Uses the renamed host-managed history value.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​resilient_long_running_workflow/​README.md Identifies the native workflow host contract.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​resilient_long_running_workflow/​main.py Migrates resilient workflow construction and parsing.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​observability/​README.md Updates history-source terminology.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​observability/​main.py Updates request-aware construction and history configuration.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​monty_codeact/​README.md Updates the documented host configuration.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​monty_codeact/​main.py Migrates the CodeAct factory and history value.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​mcp/​README.md Updates history-source terminology.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​mcp/​main.py Migrates the MCP sample factory and history value.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​foundry_toolbox/​README.md Updates host-managed history documentation.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​foundry_toolbox/​main.py Updates the Toolbox factory signature and configuration.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​foundry_toolbox_mcp_skills/​README.md Updates history-source terminology.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​foundry_toolbox_mcp_skills/​main.py Migrates request-aware Toolbox/skills construction.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​foundry_memory/​README.md Documents request-aware factories and renamed history.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​foundry_memory/​main.py Updates the Memory factory and history configuration.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​files/​README.md Updates the documented host configuration.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​files/​main.py Migrates file-tool factory construction and history.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​declarative_customer_support/​README.md Documents the dedicated workflow host.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​declarative_customer_support/​main.py Migrates declarative workflow hosting and parsing.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​custom_storage/​README.md Updates history-source terminology.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​custom_storage/​main.py Updates the agent factory while retaining custom storage.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​basic/​service_history.py Uses inference_service history.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​basic/​README.md Explains renamed policies and storage-alias migration.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​basic/​provider_background.py Updates factory, history, and background settings.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​basic/​options.py Migrates the request annotation and history value.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​basic/​main.py Uses host_managed history.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​basic/​agent_history.py Uses agent_managed history.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​azure_search_rag/​README.md Updates history-source terminology.
python/​samples/​04-hosting/​foundry-hosted-agents/​responses/​azure_search_rag/​main.py Migrates the Search factory and history configuration.
python/​samples/​04-hosting/​foundry-hosted-agents/​README.md Aligns shared sample guidance with the renamed API.
python/​samples/​04-hosting/​foundry-hosted-agents/​invocations/​basic/​workflow.py Uses the native Invocations host and parse_input.
python/​samples/​04-hosting/​foundry-hosted-agents/​invocations/​basic/​README.md Documents separate hosts and required workflow factories.
python/​samples/​04-hosting/​foundry-hosted-agents/​invocations/​basic/​main.py Renames the agent parser to parse_input.
python/​samples/​02-agents/​harness/​build_your_own_claw/​claw_step04_production_ready/​README.md Updates the documented history configuration.
python/​samples/​02-agents/​harness/​build_your_own_claw/​claw_step04_production_ready/​hosted.py Migrates the hosted harness factory and history value.
python/​samples/​01-get-started/​07_hosting.py Updates introductory hosting configuration.
python/​packages/​foundry_hosting/​tests/​test_responses_int.py Migrates history/storage tests and native crash-recovery coverage.
python/​packages/​foundry_hosting/​tests/​test_request.py Updates request contracts and shared-helper imports.
python/​packages/​foundry_hosting/​tests/​test_invocations.py Covers factory contracts, request timing, and wrapper rejection.
python/​packages/​foundry_hosting/​tests/​test_foundry_hosting_imports.py Tests exports, signatures, lazy imports, and invalid construction.
python/​packages/​foundry_hosting/​tests/​foundry_hosting/​test_workflow_state.py Updates resolver tests and verifies agent-source rejection.
python/​packages/​foundry_hosting/​tests/​foundry_hosting/​test_native_responses.py Migrates native-host tests and adds isolation/prefix coverage.
python/​packages/​foundry_hosting/​tests/​foundry_hosting/​test_invocations_workflow.py Migrates workflow tests and checks shared-resource rejection.
python/​packages/​foundry_hosting/​README.md Documents host selection, ownership, and breaking migrations.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_workflow_state.py Imports workflow contracts from shared internals.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_shared.py Consolidates contracts, options, and factory validation/resolution.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_responses_workflow.py Exposes the dedicated native Responses workflow host.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_request.py Removes request definitions relocated to _shared.py.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_invocations_workflow.py Adds the workflow-specific Invocations constructor.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_invocations_shared.py Shares protocol execution behind separate public hosts.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_invocations_agent.py Adds the agent-specific Invocations constructor.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_agent_source.py Removes factory helpers relocated to _shared.py.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​__init__.py Updates lazy public exports and removes the old request name.
python/​packages/​core/​agent_framework/​foundry/​__init__.pyi Adds typing exports for workflow hosts and ResponsesRequest.
python/​packages/​core/​agent_framework/​foundry/​__init__.py Adds matching lazy runtime exports.
docs/​decisions/​0055-python-foundry-hosting-contracts.md Records proposed contracts and outstanding implementation boundaries.

Review effort: Balanced

@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)): f6299f152332
Model: gpt-5.6-sol

Overview

The PR cleanly separates agent and native-workflow hosts, adds explicit request-aware factory contracts, and preserves strong checkpoint, continuation, option-boundary, and request-owned cleanup guards with broad regression coverage. The factory signature checks, workflow state validation, and exact pending-reply matching substantially constrain misuse. One Medium compatibility defect remains: making workflow factories mandatory exposes an existing ownership check that rejects ordinary reusable stateless function tools after their first request.

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

Affected areas: python/packages/foundry_hosting/agent_framework_foundry_hosting/_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.

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

Additional design question.

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

Additional design question.

)

* Python: split Foundry agent and native workflow hosts

* Python: require named request factories and clarify hosting contracts
* 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
Adapt #10337 (commit 6603400) to the RC branch shared storage module.
…dAgentRequest and extra_fields policy (#10353)

* Python: Unify hosted agent input handling with AgentTurn and extra_fields policy

Introduce a shared AgentTurn parse_input result for Responses and Invocations agent hosts, replace unsupported_options with an extra_fields policy, remove prepare_options hooks, and stop forwarding request fields as run options by default. Fixes #10346.

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

* Rename AgentTurn to  ParsedHostedAgentRequest

* Expand MAF

* Fix long lines

* Formatting

* Reject background execution in Invocations agent defaults

* Remove legacy Invocations wire format support

* Fix hosted agent input handling

* Python: add generic chat options to parsed hosted requests

* Python: stop inspecting extra_body and parser option keys in hosting

Parsers own the options they return; the host only checks the mapping shape.
A literal extra_body request key is reported like any other unconsumed field,
and agent default extra_body contents are no longer validated.

* Fix hosted agent input handling

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <github@vanvalkenburg.eu>
Use typed ChatOptions values (or explicit ParsedHostedAgentRequest
specialization) in tests so mypy, zuban, pyrefly and ty accept the
OptionsT bound, and import assert_type from typing.
- Rename Invocations workflow JSON helpers to describe what they do.
- Drop redundant 'X as X' re-export aliases from agent_framework.foundry stub (__all__ already re-exports).
- Use the imported host classes in the host_type test fixture.
- Remove private module references from the foundry_hosting README.
The split workflow host stages checkpoints through its run state, so the
_last_checkpoint_id response metadata key has no reader.
* keep citations as annotation types

* use all retrieved sources for citations

* extend citation fix to core

* update test helper functions

* offset improvements and source quantity limitations

* test updates

* include citations in structured_only

* Python: preserve workflow checkpoint and citation ordering

* Python: type the workflow interruption test helper

* Python: retain workflow citations through paused continuations

---------

Co-authored-by: eavanvalkenburg <github@vanvalkenburg.eu>
* Python: harden Foundry hosting input, consent, Toolbox, and logging defaults

- Default Responses parser accepts only user messages and replies to host-issued
  requests; other roles and item types are HTTP 400 before a response is created.
  Host-managed history no longer replays stored input the parser did not accept,
  and call outputs must answer an unanswered host-issued call.
- OAuth consent links default to known Foundry consent origins (overridable),
  also on the Invocations workflow host.
- FoundryToolbox requires an HTTPS Foundry endpoint unless opted out.
- Reject a reused response ID before the agent runs.
- Enforce the 50 MB inline file limit before the turn is stored.
- Stop passing platform identity to tools as runtime kwargs.
- Gate consent URLs and Invocations tracebacks behind sensitive-data logging.
- Document the security model, local-run limits, and add input parsing samples.

* Move Foundry request scope into shared module

* Python: prepare synchronous Foundry input and normalized options

* Python: prepare Foundry request options eagerly

* Python: clarify hosted request input guidance
* Python: validate hosted MCP approval batches

* Fix sequential hosted approval batches
…10456)

* Python: Keep Foundry workflow usage additive across replace snapshots

Scope replace usage snapshots to their producer in the Foundry hosting
output tracker. A replace snapshot now replaces only the cumulative usage
of the same workflow executor run, instead of wiping usage restored from a
checkpoint and usage from other agents or earlier runs.

Relates to #10189.

Co-authored-by: Mahdi-Hasan <43575088+Mahdi-Hasan@users.noreply.github.com>

* Python: Keep usage of earlier agent runs in streamed replace snapshots

Agent runs restart their cumulative `replace` usage snapshots, so when one
AgentExecutor invocation runs its agent more than once (for example handoff
autonomous mode) or AgentLoopMiddleware streams several iterations, a consumer
that honors `replace` dropped the usage of the earlier runs. Rebase later
`replace` snapshots onto the usage of completed runs without mutating the
agent's own updates, so per-run responses are unchanged.

Co-authored-by: Mahdi-Hasan <43575088+Mahdi-Hasan@users.noreply.github.com>

---------

Co-authored-by: Mahdi-Hasan <43575088+Mahdi-Hasan@users.noreply.github.com>
* Python: Support attachment replies in hosted workflows

* Python: Harden hosted attachment continuation

* Python: Validate typed content parts in hosted workflow replies
* Python: Refine Foundry hosting RC contracts

* Python: Complete hosting follow-up tests and docs

* Python: Address Foundry hosting review feedback

* Python: Defer Cost Control classification
* Python: [BREAKING] Improve Foundry hosting storage and history

* Fix Foundry hosting storage review feedback

This branch was previously deployed

1 inactive (outdated) deployment
github-app-auth — 14a0d635 Deployed Nov 17, 2026 by dargilco via add_label #27951
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

6 participants