Prototype SDK-provided durable entrypoint - #476
Conversation
|
Interface comparison set:
The first three use the same tiny progress agent and the same run/heartbeat/event durability semantics so the developer-facing differences are directly comparable. |
6aa11af to
61838a7
Compare
elainewang-db
left a comment
There was a problem hiding this comment.
Can we make a new template with using our new durable runtime for now? I think we should keep the old templates with the purpose of illustrating how people can think about writing their existing agents with our databricks_mason sdk. we can point mason init to pull in the new template by default, wdyt?
In a follow up, we really should spend some time organizing the templates and pulling out the common and sdk agnostic pieces, so that the template folders themselves only have the minimum of what they need and the common pieces are all shared and copied in by mason init.
|
Addressed Elaine’s template-scope feedback: this PR now leaves all existing LangGraph/OpenAI/chat templates unchanged and adds only the minimal This comment was generated with GitHub MCP. |
08b5e7a to
8dbb56d
Compare
| if claimed is None: | ||
| return | ||
|
|
||
| heartbeat = asyncio.create_task( |
There was a problem hiding this comment.
qq: when execution fails -- do we also cleanup the heartbeat task?
What changed
This adds a small SDK-provided durable runtime and FastAPI application to
databricks-mason, plus one new minimal LangGraph example nameddurability-app.The runtime library lives under Mason's existing package:
runtime.pyowns durable execution, heartbeats, attempt fencing, recovery, and event replay.store.pyprovides the in-memory and Lakebase-backed stores.app.pyis the thin HTTP adapter over the runtime.types.pycontains the public callback/context/store contracts.Public imports are available from either
databricks_masonordatabricks_mason.runtime.Template scope
This PR does not modify the existing LangGraph, OpenAI, or chat UI templates. Their effective diff against
origin/mainis empty.It adds only:
The app is intentionally deterministic and has no model dependency: one LangGraph node optionally waits and returns
Processed: <message>.runtime/main.pyonly constructsDurableAgentAppand exports its FastAPI app.Bare
mason initselectsdurability-app. Explicit--framework langgraphand--framework openairetain the existing templates and behavior. Migration/cleanup of those existing templates is deferred to a separate follow-up PR.HTTP contract
id.__Host-databricks-app-routeris the only routing/session cookie.POST /invocationsandPOST /api/invocationssupport foreground, background, and streaming modes.GET /invocations/{id}andGET /invocations/{id}/eventshave/apialiases./api/healthzroute.on_resumeis configured.Lakebase durability
Only projects scaffolded from
durability-appautomatically configure runtime durability.mason deploy --session <store>is supplied, Mason reuses that Session Store's Lakebase database.<app>-durabilityLakebase project.Mason adds only the
databricks_mason_runtimeschema and itsexecutions/execution_eventstables to the selected database. The selected endpoint is injected asDATABRICKS_MASON_RUNTIME_ENDPOINT. Local execution falls back to an in-memory store.--no-create-storesprevents dedicated fallback provisioning.Live end-to-end test (
e2-dogfood)Validated commit
bcb2017busing a disposable copy of the new template. The temporary source included the locally built Mason wheel and uncommitted startup assertions; none of that test-only wiring is part of this PR.Build and deploy
cd integrations/mason uv build uv run mason --profile e2-dogfood --output json deploy \ p476d-bcb2017 \ --source /tmp/pr476-live-bcb2017.fH0pcU databricks apps get mason-p476d-bcb2017 \ --profile e2-dogfood \ --output jsonThe deployment succeeded and attached exactly one Postgres resource:
Mason injected:
Exercise foreground, background, replay, and persistence
The disposable app exercised the real FastAPI routes from inside the deployed process using ASGI transport and a fixed
__Host-databricks-app-routercookie. It verified:409;startedandcompletedevents;Lakebase was inspected using:
Before restart,
databricks_mason_runtimecontained:The schema contained exactly:
Stop/start recovery
After restart, the same persisted row was:
execution_eventscontainedstage=recovered, attempt=2, followed bystage=completed, attempt=2. A separaterecovery-markerforeground invocation also completed after restart.Cleanup
Follow-up
getcalls confirmed the temporary App, workspace source, and Lakebase project no longer exist.Validation
Validated on the latest
origin/main(5e75997ca8f51a526a742d95fb0ecfdefad5fc44):345 passeddurability-apptests:3 passedruff checkruff format --checkty checkuv lock --checkgit diff --checkagent_durability_store.pyandruntime/{app,runtime,store,types}.pyorigin/maine2-dogfooddeployment, Lakebase persistence, and stop/start recovery passed