Repository navigation
Python: [BREAKING] Split Foundry agent and native workflow hosts - #10224
Eduard van Valkenburg (eavanvalkenburg) wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): a696e1ebfc72
Model: gpt-5.6-sol
Overview
The PR cleanly separates agent and native-workflow hosts while preserving protocol behavior through explicit constructor validation, request-aware factories, checkpoint-owned workflow state, and synchronized runtime/type exports. Fresh-graph identity checks, strict pending-reply validation, bounded Invocations snapshots, cancellation-shielded cleanup, and extensive lifecycle tests address the highest-risk migration paths. The review found no Critical, High, or Medium defect introduced by this change.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: No findings
Scope: 1 net-new commit(s): 5a6635104e1e
Model: gpt-5.6-sol
Overview
This increment replaces ambiguous agent-factory dispatch with an explicit named request contract and validates that contract before SDK construction. The implementation calls factories once by keyword, rejects incompatible signatures and workflow-agent results, and adds regression coverage for ambiguous signatures, configured factories, exception behavior, ownership, and cleanup. Those guards and the documented breaking migration leave no publishable Critical, High, or Medium finding in the authoritative incremental range.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
Agent and native workflow hosting have different construction, history, and persistence contracts. Separate host classes make the supported execution model and its required inputs explicit instead of exposing mode-dependent settings through a combined constructor.
This targets the coordinated
python-foundry-hosting-rcfeature branch. It implements the agreed host split and the parser/request and source naming choices approved by Eduard during implementation. At his request, it also consolidates the #10015/#10018 work from the now-closed #10187 so those changes do not need to be reapplied across moved modules.Description & Review Guide
ResponsesHostServerandInvocationsHostServerfor agents; addResponsesWorkflowHostServerandInvocationsWorkflowHostServerfor native workflows. Require request-aware native workflow factories and explicitparse_inputcallbacks. Support request-aware agent factories while retaining zero-argument factories. RenameHostedResponseRequesttoResponsesRequest, align history/background source literals, and remove the constructorstore=alias. Group implementation into_responses_agent,_responses_workflow,_responses_shared, equivalent Invocations modules, and a cross-protocol_shared. Update exports, regression tests, maintained samples, migration guidance, consumer documentation, and proposed ADR 0055.WorkflowAgentinstances and factory results; workflow hosts reject agents and built workflow instances. Workflow hosts expose checkpoint storage instead of agent-session/history settings. Factory construction retains the existing shared-execution-resource guard: a fresh graph around shared executors is not sufficient. Defaults retain their meaning, and wire formats, option precedence, agent approval-store APIs, checkpoint-owned workflow pending authority, ownership, and supported agent inference-service background behavior remain unchanged. The supportedresponse_store=backend and wire-level per-requeststoreflag are preserved. Responses remains the initial stable-surface target; Invocations and Toolbox stay experimental in one package.Before:
After:
The application supplies
build_workflowandparse_workflow_turn. Parsers still return either typed start input or complete validated pending replies. Invocations agent and workflow parser keywords also becomeparse_input; agent parsers returnInvocationRun, while workflow parsers returnWorkflowTurn.Responses agent construction still uses
agent=, withhistory_source="host_managed"(default),"agent_managed", or"inference_service"instead of"agent_server","agent", or"service". Background sources become"host_managed"(default) and"inference_service"instead of"agent_server"and"provider".agent_managedretains developer-owned provider or service storage. Useresponse_store=backend, not the removed constructorstore=backend; evenstore=Noneis rejected before SDK construction.Responses factories receive
ResponsesRequestbeforeprepare_options; Invocations factories receive the StarletteRequestafter parsing and option preparation. When both request and zero-argument call shapes bind, the request form wins. Factory-body exceptions do not trigger a retry with another call shape. Factory-owned context-managed agents are entered and closed per request.Agent foreground/background execution remains separate from recovery permission. Supported inference-service agent background still requires inference-service history. Outer workflow background does not enable provider background on workflow agents. Native workflow state and pending replies remain checkpoint-owned. This does not redesign concurrency, checkpoints, retries, approvals, consent, routing, dependencies, or the SDK options surface, and the identity guard is not a proof of arbitrary global-state isolation.
Checks completed locally:
uv run --directory python poe test -P foundry_hosting— passed: 1,137 tests, 36 integration tests deselected, 91% coverage.uv run --directory python poe syntax -P foundry_hosting— passed.uv run --directory python poe pyright -P foundry_hosting— passed, no errors or warnings.uv run --directory python poe test-typing -P foundry_hosting— passed all five configured test checkers.uv run --directory python/packages/foundry_hosting pytest -q --import-mode=prepend -m integration --runxfail tests/test_responses_int.py::TestWorkflowResilientRecoveryRealCrash— passed all eight model-free real-process crash/recovery cases.prependavoids an existing installed Core test-namespace collision; the existing readiness xfail marker is otherwise unchanged.uv run --directory python pytest -q -c packages/core/pyproject.toml packages/core/tests/core/test_foundry_namespace.py— passed both tests.uv run --directory python -m scripts.check_md_code_blocks packages/foundry_hosting/README.md --no-glob— passed. The same checker also passed for all 20 changed Python Markdown documents.asynccontextmanager/AsyncIteratordeprecation athosted.py:163, verified in the base revision and left outside this change.git diff --check— passed.Credentialed integration tests, live Foundry deployment, and a distribution build were not run.
Related Issue
Fixes #10010
Fixes #10014
Fixes #10015
Fixes #10018
Relates to #7688: includes only the narrowly coupled factory construction and existing resource-isolation guard coverage, not the broader workflow roadmap.
Supersedes closed #10187 at Eduard's request, including both its source-literal changes and constructor-alias removal. No competing open PR was found for these issues. The host split has explicit maintainer agreement in #10010; the final public names, migration, and consolidation were approved during the dedicated implementation session.
AI Assistance
AI assistance details: Copilot assisted with implementation, module restructuring, regression tests, samples, migration documentation, validation, 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.