(_: FastAPI)
| 71 | |
| 72 | @asynccontextmanager |
| 73 | async def lifespan(_: FastAPI) -> AsyncIterator[None]: |
| 74 | # Lazy-init shared resources once per process. |
| 75 | app.state.e2a = E2AClient() |
| 76 | app.state.sessions = InMemorySessionService() |
| 77 | app.state.runner = Runner( |
| 78 | agent=agent, app_name=APP_NAME, session_service=app.state.sessions |
| 79 | ) |
| 80 | yield |
| 81 | |
| 82 | |
| 83 | app = FastAPI(title="ADK + e2a webhook", lifespan=lifespan) |