From 421d4957f89945618010931d785e99f32bc360f1 Mon Sep 17 00:00:00 2001 From: snooyen Date: Mon, 24 Nov 2025 10:53:55 -0800 Subject: [PATCH 1/3] feat(a2a): updates advanced server customization example code to demonstrate passing additional keyword arguments to FastAPI and Starlette constructors --- .../concepts/multi-agent/agent-to-agent.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/concepts/multi-agent/agent-to-agent.md b/docs/user-guide/concepts/multi-agent/agent-to-agent.md index f0b0625e..b152fd52 100644 --- a/docs/user-guide/concepts/multi-agent/agent-to-agent.md +++ b/docs/user-guide/concepts/multi-agent/agent-to-agent.md @@ -86,6 +86,7 @@ The `A2AServer` constructor accepts several configuration options: The `A2AServer` provides access to the underlying FastAPI or Starlette application objects allowing you to further customize server behavior. ```python +from contextlib import asynccontextmanager from strands import Agent from strands.multiagent.a2a import A2AServer import uvicorn @@ -94,13 +95,22 @@ import uvicorn agent = Agent(name="My Agent", description="A customizable agent", callback_handler=None) a2a_server = A2AServer(agent=agent) +@asynccontextmanager +async def lifespan(app: FastAPI): + """Manage application lifespan with proper error handling.""" + # Startup tasks + yield # Application runs here + # Shutdown tasks + # Access the underlying FastAPI app -fastapi_app = a2a_server.to_fastapi_app() +# Allows passing keyword arguments to FastAPI constructor for further customization +fastapi_app = a2a_server.to_fastapi_app(lifespan=lifespan) # Add custom middleware, routes, or configuration fastapi_app.add_middleware(...) # Or access the Starlette app -starlette_app = a2a_server.to_starlette_app() +# Allows passing keyword arguments to FastAPI constructor for further customization +starlette_app = a2a_server.to_starlette_app(lifespan=lifespan) # Customize as needed # You can then serve the customized app directly From 4450b61a8386a20507c9eb082afb5dc66e19159e Mon Sep 17 00:00:00 2001 From: Aaron Farntrog Date: Wed, 17 Dec 2025 13:23:50 -0500 Subject: [PATCH 2/3] update docs to use dict --- docs/user-guide/concepts/multi-agent/agent-to-agent.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/concepts/multi-agent/agent-to-agent.md b/docs/user-guide/concepts/multi-agent/agent-to-agent.md index b152fd52..8e864371 100644 --- a/docs/user-guide/concepts/multi-agent/agent-to-agent.md +++ b/docs/user-guide/concepts/multi-agent/agent-to-agent.md @@ -104,13 +104,13 @@ async def lifespan(app: FastAPI): # Access the underlying FastAPI app # Allows passing keyword arguments to FastAPI constructor for further customization -fastapi_app = a2a_server.to_fastapi_app(lifespan=lifespan) +fastapi_app = a2a_server.to_fastapi_app(app_kwargs={"lifespan": lifespan}) # Add custom middleware, routes, or configuration fastapi_app.add_middleware(...) # Or access the Starlette app # Allows passing keyword arguments to FastAPI constructor for further customization -starlette_app = a2a_server.to_starlette_app(lifespan=lifespan) +starlette_app = a2a_server.to_starlette_app(app_kwargs={"lifespan": lifespan}) # Customize as needed # You can then serve the customized app directly From 7ed061135d0e0d0d0e5985ac8ebe9a649ee49fae Mon Sep 17 00:00:00 2001 From: Aaron Farntrog Date: Wed, 17 Dec 2025 15:12:18 -0500 Subject: [PATCH 3/3] dont fail linter on 307 --- .github/workflows/build-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 09a8ea77..6502710c 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -56,4 +56,4 @@ jobs: id: lychee uses: lycheeverse/lychee-action@v2 with: - args: "--cache --max-cache-age 1d 'docs/**/*.md'" + args: "--cache --max-cache-age 1d --accept 200..=299,307 'docs/**/*.md'"