Add DatabricksDurableRuntime for Lakebase-backed execution - #466
Closed
shivam5 wants to merge 2 commits into
Closed
Conversation
shivam5
force-pushed
the
long-running-durability
branch
from
August 19, 2026 21:28
cce5db7 to
e249c6e
Compare
shivam5
marked this pull request as ready for review
August 19, 2026 21:38
shivam5
marked this pull request as draft
August 19, 2026 21:38
elainemwang
reviewed
Aug 19, 2026
| http_request: Request, | ||
| ) -> ResponsesAgentResponse: | ||
| if request.stream: | ||
| raise HTTPException(400, "streaming is not implemented by this example") |
Contributor
There was a problem hiding this comment.
can we expose a durable_runtime.run_foreground method for streaming?
This was referenced Aug 19, 2026
Contributor
Author
|
Questions to answer:
|
Contributor
Author
|
Contributor
Author
|
For resumption, should we expose a handler/hook such |
Contributor
Author
|
We want to go with server approach, and handle durable streaming, and want to generalize longRunningAgentServer - moved PR to #467 |
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.
What did you change, and why?
Change: Add a standalone, transport-neutral DatabricksDurableRuntime and LakebaseDurabilityStore. The runtime persists one idempotent JSON request per execution_id, heartbeats the active attempt, atomically claims queued or stale work, passes the exact persisted request to a caller-owned executor, and stores the terminal JSON response in the same Lakebase row.
The public contract supports background submit, blocking invoke, status/result get, and wait. Reusing an ID with the same request returns the cached response; reusing it with a different request raises a conflict. DurableExecutionContext exposes the attempt number so an agent harness can decide how to use its own session/checkpointer history during recovery.
This PR also adds a complete OpenAI Agents SDK Databricks App example. It keeps the existing PR-review agent and AsyncDatabricksSession, replaces the application-owned durability package with DatabricksDurableRuntime, and shows the thin FastAPI adapter for blocking invocation, background submission, status/result retrieval, exact-request replay, and conflict handling. The example README separates runtime, HTTP adapter, agent, and SDK-session responsibilities; live observations record the Lakebase state across each scenario.
Why: The OpenAI SDK agent experiment showed that heartbeat/restart and request/response recovery are reusable runtime concerns, while SDK session history must remain harness-managed. This separates those layers and makes the required HTTP/idempotency wiring explicit without coupling durability to MLflow, FastAPI, or an agent SDK.
LongRunningAgentServer is unchanged in this PR. Making it extend DatabricksDurableRuntime is intentionally deferred.
How do you know it works?
Automated testing: Added 20 focused tests covering request conflicts, cached responses, background and blocking execution, cross-process polling, stale recovery with the exact request, attempt metadata, failure state, timeouts that leave execution running, store schema/JSON persistence, and subclass wiring. Repository-wide Ruff format/check passes. Repository-wide ty check has only three pre-existing warnings outside this change, and the example passes a dedicated ty check against MLflow 3.10.1 and the current OpenAI integration.
Live testing: Built this PR as local wheels and deployed the example to Databricks Apps with Lakebase. Verified:
The commands, IDs, timing, message counts, request/response state, and recovery-history evidence are documented in examples/openai-sdk-agent/OBSERVATIONS.md. Built the wheel and verified all durable_runtime modules and its README are packaged.