Add agent-openai-scratch template (raw FastAPI) - #264
Draft
elainemwang wants to merge 13 commits into
Draft
Conversation
An OpenAI Agents SDK agent served from a hand-written FastAPI app instead of MLflow's
AgentServer. mason/wire/serve.py builds the Responses API surface: /invocations + /responses
(sync, SSE streaming, in-memory background), GET /responses/{id}, /health, with per-request
MLflow spans. Local-first (SQLite sessions), optional managed session store + tracing.
Co-authored-by: Isaac <no-reply@databricks.com>
…r types) Handlers and the wire layer now pass plain Responses-shaped dicts instead of ResponsesAgentRequest/Response. session_id round-trips as a top-level request/response field (no custom_inputs/custom_outputs). Removes mlflow.types.responses from the wire layer. Co-authored-by: Isaac <no-reply@databricks.com>
The FastAPI endpoints (build_app) only depend on the invoke_handler/stream_handler dict contract, not the agent SDK — so they live in server/app.py, and start_server.py just wires the agent's handlers in and runs uvicorn. Another SDK's template can reuse server/app.py verbatim. Co-authored-by: Isaac <no-reply@databricks.com>
Removes the input dedup + MLflow-eval string-content coercion. With a session_id the session supplies prior history, so clients send only the new turn's message. inbound.py is now just get_session_id. Tracing is unaffected (lives in server/app.py + mason/tracing.py). Co-authored-by: Isaac <no-reply@databricks.com>
outbound.py now serializes each StreamEvent under its own type ({type, data} for
raw_response_event; {type, name, item} for run_item_stream_event) instead of reshaping into
Responses events. The client receives the SDK's native event shape as JSON — no imposed
contract — symmetric with how the langgraph template will emit its native events.
Co-authored-by: Isaac <no-reply@databricks.com>
The hand-rolled server's span name wasn't surfacing as the trace name; set the mlflow.traceName tag explicitly in each handler's span so traces are labeled in the UI. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
deploy.yml ran databricks bundle (needs a databricks.yml this template doesn't ship) and hardcoded a stale app name; this template deploys via 'databricks apps deploy' (see README). Also corrects wire/__init__ + README to say outbound serializes SDK events (no Responses reshaping). Co-authored-by: Isaac <no-reply@databricks.com>
Removes the gallery resource contract so this template isn't offered in the Create-App-from- Template flow; it's provisioned/configured via the CLI (env + resources) or manual apps deploy. Follows templates like rag-chat / content-moderator that ship without a manifest. Co-authored-by: Isaac <no-reply@databricks.com>
elainemwang
commented
Aug 26, 2026
| return f"data: {json.dumps(data) if isinstance(data, dict) else data}\n\n" | ||
|
|
||
|
|
||
| class _BackgroundRuns: |
Author
There was a problem hiding this comment.
if we go with the durable execution library approach, that would be able to replace this class fully.
Relocates the background-run store out of server/app.py into its own mason module (public BackgroundRuns, durability-swap docstring). server/app.py imports it and is now byte-identical to the agent-langgraph-scratch template's serving layer. Docs point the store at mason/background.py while server/app.py does the wiring. Co-authored-by: Isaac <no-reply@databricks.com>
…sts to AGENTS Neither is imported since dropping AgentServer; verified boot + tracing + tool calls still work without them. AGENTS.md gains a Sample requests section (sync / streaming / background / multi-turn). Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
README is the canonical request reference (literal http://localhost:8000 URLs, copy-pasteable); AGENTS drops its duplicate sample-requests block and links to the README Client contract section. Co-authored-by: Isaac <no-reply@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An OpenAI Agents SDK agent served from a hand-written FastAPI app. mason/wire/serve.py builds the Responses API surface: /invocations + /responses (sync, SSE streaming, in-memory background), GET /responses/{id}, /health, with per-request MLflow spans. Local-first (SQLite sessions), optional managed session store + tracing.