This template implements a production-ready agentic DAG with the OpenAI Agents SDK and Prefect. It includes a minimal wrapper layer that exposes core SDK features (guardrails, sessions, tracing, streaming, MCP approvals, handoffs) using Pydantic configuration.
- Install dependencies
uv sync- Configure environment
cp .env.example .env- Start the local MCP stub (Streamable HTTP)
uv run python -m src.mcp_stub_server- Start Prefect UI
prefect server start- Run the flow
uv run python -m src.flows.work_order_flowOpen the Prefect UI at http://127.0.0.1:4200 to visualize the DAG.
- Streaming + sessions demo:
uv run python -m src.projects.interactive_assistant- Guardrails: input/output guardrails and tool guardrails in
src/wrapper/guardrails.py. - Sessions: SQLite-backed sessions via
src/wrapper/sessions.py. - Tracing: controlled by
TRACING_*env vars andRunConfiginsrc/config.py. - Streaming: helper in
src/wrapper/runner.pyforRunner.run_streamed(). - Approvals: hosted MCP approval hook in
src/wrapper/approvals.py. - Handoffs: helper in
src/wrapper/handoffs.py. - Pydantic config:
src/config.pyusesBaseModelandAppConfig.from_env().
- MCP server endpoint is configured with
MCP_URL(defaults tohttp://localhost:8000/mcp). - The MCP stub exposes
search_docs,read_metrics,create_task,update_tickettools. - To enable hosted MCP approvals, set
USE_HOSTED_MCP=trueandMCP_HOSTED_URL.
- OpenAI Agents SDK (agents, handoffs, MCP): https://openai.github.io/openai-agents-python/
- OpenAI Agents SDK repository: https://github.com/openai/openai-agents-python
- Prefect flow run pause/resume: https://reference.prefect.io/prefect/flow_runs/