Files
Eduard van Valkenburg f2d02e58b3 Python: Add hosting core and Responses channel (#6580)
* Add Python hosting core and Responses channel

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

* Address hosting core review feedback

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

* Adopt source pyright typing setup for hosting packages

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

* Cover ResponsesChannel custom path routing

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

* Align hosting tests with package layout

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

* Fix hosting workflow fixture imports in aggregate tests

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

* Apply useful Responses channel hardening

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

* Fix hosting package typing checks

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

* Fix hosting pyright under Python 3.11

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

* Avoid static diskcache dependency in hosting

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

* Fix aggregate typing and Docker test resilience

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

* Simplify local Responses workflow sample

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

* Clarify generic hosting is not Foundry hosting

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

* Revert "Clarify generic hosting is not Foundry hosting"

This reverts commit 73b584d919053bed43a258d75dc2b76406e9c181.

* Clarify isolation key source flexibility

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

* Clarify isolation header reuse boundary

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

* Support multimodal Responses channel outputs

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

* Preserve multimodal streaming Responses output

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

* Stream Responses output items from updates

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

* Improve Responses streaming output handling

* Tighten Responses channel default option handling

- Restore full option parsing in parse_responses_request: known fields
  are remapped (max_output_tokens→max_tokens, parallel_tool_calls→
  allow_multiple_tool_calls), transport/session keys excluded, None
  values dropped, everything else forwarded as-is so run_hook can
  inspect the full set.
- Add a default _strip_options_hook on ResponsesChannel that removes
  all parsed options before reaching the agent. Callers cannot inject
  generation params (temperature, instructions, tools, …) unless the
  host explicitly allows it.
- A custom run_hook replaces the default entirely and receives the
  full ChannelRequest.options plus the raw protocol_request.
- Update tests to cover remap, default-strip, and custom-hook paths.
- Clarify host debug-log docstring to match new option flow.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 20:56:46 +00:00
..

Multi-channel hosting samples

End-to-end samples for serving an agent-framework agent (or workflow) through one or more channels with agent-framework-hosting.

The general hosting plumbing lives in agent-framework-hosting; each channel is its own package. This first sample set includes agent-framework-hosting-responses.

Sample What it shows Packaging
local_responses/ The minimal shape: one agent + one @tool + ResponsesChannel + a single run_hook that strips caller-supplied options and forces a reasoning preset. Local only. Start here to learn the run-hook seam.
local_responses_workflow/ A 4-step Workflow (typed SloganBrief intake → writer → legal → formatter) hosted behind the Responses channel via a run_hook that parses inbound text/JSON into the workflow's typed input. The host writes per-conversation checkpoints via checkpoint_location=…. Demonstrates workflow targets + structured input adaptation + resume-across-turns. Includes a call_server.rest file with REST examples. Local only.

Each sample is fully self-contained — its own pyproject.toml, uv.lock, server app.py, calling script(s), and storage/ directory. Every sample uses [tool.uv.sources] to wire its agent-framework-hosting* dependencies to the main branch of the upstream repo via git refs, so they install cleanly outside the monorepo while the hosting packages are still pre-PyPI. Once those packages publish, drop the [tool.uv.sources] block and let the declared deps resolve from PyPI.

Relationship to ../foundry-hosted-agents/

The sibling ../foundry-hosted-agents/ directory contains samples for the agent-framework-hosted stack — agents that run inside the Foundry Hosted Agents platform using its built-in protocol surface (Responses, Invocations, conversation store, isolation, identity), with no agent-framework-hosting package involved.

Aspect af-hosting/ (this directory) foundry-hosted-agents/
Server stack agent-framework-hosting + agent-framework-hosting-responses agent-framework-hosted only — the Foundry Hosted Agents runtime owns the HTTP surface
Channels Responses only in this initial sample set The platform exposes Responses + Invocations
Run target Local Hypercorn (local_responses/, local_responses_workflow/) Hosted Agents or local container; targets the Hosted Agents platform contract
When to pick this You want to learn the host/channel seams locally or need custom hosting middleware You want zero hosting boilerplate, leveraging the Foundry-managed surface

The table above summarizes the cross-sample story.