From 34d5c12f0273380b19341148c9bf624ba3e2d52e Mon Sep 17 00:00:00 2001 From: eavanvalkenburg Date: Tue, 14 Jul 2026 10:53:32 +0200 Subject: [PATCH 1/3] docs: add self-hosting sample snippets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 636b7fb2-381a-4d62-b5cf-d029efa3ad20 --- python/samples/04-hosting/README.md | 2 ++ python/samples/04-hosting/af-hosting/local_responses/app.py | 2 ++ .../04-hosting/af-hosting/local_responses_workflow/app.py | 2 ++ python/samples/04-hosting/af-hosting/local_telegram/app.py | 2 ++ python/samples/AGENTS.md | 1 + 5 files changed, 9 insertions(+) diff --git a/python/samples/04-hosting/README.md b/python/samples/04-hosting/README.md index 351039b8d66..cb7af1a78be 100644 --- a/python/samples/04-hosting/README.md +++ b/python/samples/04-hosting/README.md @@ -10,6 +10,7 @@ This directory contains Python samples that demonstrate different ways to host A | Azure Functions | HTTP or serverless hosting on Azure Functions. | [`azure_functions/README.md`](./azure_functions/README.md) | | Durable Task | Durable execution, long-running flows, or orchestration patterns. | [`durabletask/README.md`](./durabletask/README.md) | | Foundry Hosted Agents | Microsoft Foundry hosted agent deployment. | [`foundry-hosted-agents/README.md`](./foundry-hosted-agents/README.md) | +| Self-hosted protocol helpers | Application-owned OpenAI Responses endpoints or Telegram bots. | [`af-hosting/README.md`](./af-hosting/README.md) | ## How to Choose @@ -17,6 +18,7 @@ This directory contains Python samples that demonstrate different ways to host A - Start with **Azure Functions** if you want an HTTP-hosted or serverless entry point using Azure Functions. - Start with **Durable Task** if you need persistent state, durable workflows, or orchestration across multiple steps. - Start with **Foundry Hosted Agents** if you want to package and deploy an agent as a hosted agent in Microsoft Foundry. +- Start with **Self-hosted protocol helpers** if you want to own the web framework or native SDK, routing, authorization, and state storage while using OpenAI Responses or Telegram helpers. ## Common Prerequisites diff --git a/python/samples/04-hosting/af-hosting/local_responses/app.py b/python/samples/04-hosting/af-hosting/local_responses/app.py index da3ae51bda5..5612bd103a4 100644 --- a/python/samples/04-hosting/af-hosting/local_responses/app.py +++ b/python/samples/04-hosting/af-hosting/local_responses/app.py @@ -104,6 +104,7 @@ def create_agent() -> Agent: ) +# app = FastAPI() state = AgentState(create_agent) @@ -177,6 +178,7 @@ async def stream_events() -> AsyncIterator[str]: session_id=session_id, ) ) +# async def main() -> None: diff --git a/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py b/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py index 4d779d66db8..977bb384b4d 100644 --- a/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py +++ b/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py @@ -217,6 +217,7 @@ async def handle(self, response: AgentExecutorResponse, ctx: WorkflowContext[Any ).add_edge(writer_ex, formatter_ex) +# app = FastAPI() state = WorkflowState(workflow_builder, cache_target=False) @@ -270,6 +271,7 @@ async def responses(body: dict[str, Any] = Body(...)) -> JSONResponse: # noqa: session_id=previous_response_id, ) ) +# async def main() -> None: diff --git a/python/samples/04-hosting/af-hosting/local_telegram/app.py b/python/samples/04-hosting/af-hosting/local_telegram/app.py index 861f4bf3715..8bc413051f4 100644 --- a/python/samples/04-hosting/af-hosting/local_telegram/app.py +++ b/python/samples/04-hosting/af-hosting/local_telegram/app.py @@ -204,6 +204,7 @@ async def resolve_file_url(file_id: str) -> str | None: encoded = base64.b64encode(data).decode("ascii") return f"data:application/octet-stream;base64,{encoded}" + # try: run = await telegram_to_run(update, resolve_file_url=resolve_file_url, stream=True) except ValueError: @@ -243,6 +244,7 @@ async def resolve_file_url(file_id: str) -> str | None: # Persist the updated AgentSession back under the stable per-chat key after # streaming has finalized and the history provider has recorded the turn. await state.set_session(session_id, session) + # @dispatcher.message() diff --git a/python/samples/AGENTS.md b/python/samples/AGENTS.md index 5d5b201a670..50a3da5941d 100644 --- a/python/samples/AGENTS.md +++ b/python/samples/AGENTS.md @@ -36,6 +36,7 @@ python/samples/ │ └── visualization/ # Workflow visualization ├── 04-hosting/ # Deployment & hosting │ ├── a2a/ # Agent-to-Agent protocol +│ ├── af-hosting/ # Native Responses and Telegram hosting │ ├── azure-functions/ # Azure Functions samples │ └── durabletask/ # Durable task framework ├── 05-end-to-end/ # Complete applications From 0917a6e16952af1949c1224340196ac3df8e1cf9 Mon Sep 17 00:00:00 2001 From: eavanvalkenburg Date: Tue, 14 Jul 2026 10:57:55 +0200 Subject: [PATCH 2/3] docs: use stable hosting sample ranges Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 636b7fb2-381a-4d62-b5cf-d029efa3ad20 --- python/samples/04-hosting/af-hosting/local_responses/app.py | 2 -- .../04-hosting/af-hosting/local_responses_workflow/app.py | 2 -- python/samples/04-hosting/af-hosting/local_telegram/app.py | 2 -- 3 files changed, 6 deletions(-) diff --git a/python/samples/04-hosting/af-hosting/local_responses/app.py b/python/samples/04-hosting/af-hosting/local_responses/app.py index 5612bd103a4..da3ae51bda5 100644 --- a/python/samples/04-hosting/af-hosting/local_responses/app.py +++ b/python/samples/04-hosting/af-hosting/local_responses/app.py @@ -104,7 +104,6 @@ def create_agent() -> Agent: ) -# app = FastAPI() state = AgentState(create_agent) @@ -178,7 +177,6 @@ async def stream_events() -> AsyncIterator[str]: session_id=session_id, ) ) -# async def main() -> None: diff --git a/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py b/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py index 977bb384b4d..4d779d66db8 100644 --- a/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py +++ b/python/samples/04-hosting/af-hosting/local_responses_workflow/app.py @@ -217,7 +217,6 @@ async def handle(self, response: AgentExecutorResponse, ctx: WorkflowContext[Any ).add_edge(writer_ex, formatter_ex) -# app = FastAPI() state = WorkflowState(workflow_builder, cache_target=False) @@ -271,7 +270,6 @@ async def responses(body: dict[str, Any] = Body(...)) -> JSONResponse: # noqa: session_id=previous_response_id, ) ) -# async def main() -> None: diff --git a/python/samples/04-hosting/af-hosting/local_telegram/app.py b/python/samples/04-hosting/af-hosting/local_telegram/app.py index 8bc413051f4..861f4bf3715 100644 --- a/python/samples/04-hosting/af-hosting/local_telegram/app.py +++ b/python/samples/04-hosting/af-hosting/local_telegram/app.py @@ -204,7 +204,6 @@ async def resolve_file_url(file_id: str) -> str | None: encoded = base64.b64encode(data).decode("ascii") return f"data:application/octet-stream;base64,{encoded}" - # try: run = await telegram_to_run(update, resolve_file_url=resolve_file_url, stream=True) except ValueError: @@ -244,7 +243,6 @@ async def resolve_file_url(file_id: str) -> str | None: # Persist the updated AgentSession back under the stable per-chat key after # streaming has finalized and the history provider has recorded the turn. await state.set_session(session_id, session) - # @dispatcher.message() From c103ae7a8d684005c6a5f27040112a953e52de0f Mon Sep 17 00:00:00 2001 From: eavanvalkenburg Date: Tue, 14 Jul 2026 11:06:46 +0200 Subject: [PATCH 3/3] docs: address hosting sample review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 636b7fb2-381a-4d62-b5cf-d029efa3ad20 --- python/samples/04-hosting/README.md | 4 ++-- python/samples/AGENTS.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/samples/04-hosting/README.md b/python/samples/04-hosting/README.md index cb7af1a78be..bea9124f86e 100644 --- a/python/samples/04-hosting/README.md +++ b/python/samples/04-hosting/README.md @@ -10,7 +10,7 @@ This directory contains Python samples that demonstrate different ways to host A | Azure Functions | HTTP or serverless hosting on Azure Functions. | [`azure_functions/README.md`](./azure_functions/README.md) | | Durable Task | Durable execution, long-running flows, or orchestration patterns. | [`durabletask/README.md`](./durabletask/README.md) | | Foundry Hosted Agents | Microsoft Foundry hosted agent deployment. | [`foundry-hosted-agents/README.md`](./foundry-hosted-agents/README.md) | -| Self-hosted protocol helpers | Application-owned OpenAI Responses endpoints or Telegram bots. | [`af-hosting/README.md`](./af-hosting/README.md) | +| Self-Hosted Protocol Helpers | Application-owned OpenAI Responses endpoints or Telegram bots. | [`af-hosting/README.md`](./af-hosting/README.md) | ## How to Choose @@ -18,7 +18,7 @@ This directory contains Python samples that demonstrate different ways to host A - Start with **Azure Functions** if you want an HTTP-hosted or serverless entry point using Azure Functions. - Start with **Durable Task** if you need persistent state, durable workflows, or orchestration across multiple steps. - Start with **Foundry Hosted Agents** if you want to package and deploy an agent as a hosted agent in Microsoft Foundry. -- Start with **Self-hosted protocol helpers** if you want to own the web framework or native SDK, routing, authorization, and state storage while using OpenAI Responses or Telegram helpers. +- Start with **Self-Hosted Protocol Helpers** if you want to own the web framework or native SDK, routing, authorization, and state storage while using OpenAI Responses or Telegram helpers. ## Common Prerequisites diff --git a/python/samples/AGENTS.md b/python/samples/AGENTS.md index 50a3da5941d..33eb3e05650 100644 --- a/python/samples/AGENTS.md +++ b/python/samples/AGENTS.md @@ -36,8 +36,8 @@ python/samples/ │ └── visualization/ # Workflow visualization ├── 04-hosting/ # Deployment & hosting │ ├── a2a/ # Agent-to-Agent protocol -│ ├── af-hosting/ # Native Responses and Telegram hosting -│ ├── azure-functions/ # Azure Functions samples +│ ├── af-hosting/ # Native Responses and Telegram hosting +│ ├── azure_functions/ # Azure Functions samples │ └── durabletask/ # Durable task framework ├── 05-end-to-end/ # Complete applications │ ├── chatkit-integration/