Skip to content

Prototype transport-neutral durable runtime library - #475

Draft
shivam5 wants to merge 4 commits into
databricks:mainfrom
shivam5:poc/durable-library-interface
Draft

Prototype transport-neutral durable runtime library#475
shivam5 wants to merge 4 commits into
databricks:mainfrom
shivam5:poc/durable-library-interface

Conversation

@shivam5

@shivam5 shivam5 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What did you change, and why?

This is a draft interface prototype for the transport-neutral library option. It is intentionally an alternative to the provided app/server interfaces, not a proposed final API.

Developer contract

runtime = DatabricksDurableRuntime(run_agent)
await runtime.start()
await runtime.submit(run_id, request)

The library stores requests, results, heartbeats, attempts, and ordered events. The developer owns FastAPI lifecycle, request mapping, 202 responses, polling, SSE formatting, cursor handling, and recovery behavior inside run_agent.

Durable CUJ in the cookbook

  • A background streamed proposal completes with requires_action.
  • The client polls the persisted result and submits approval as a second run with the same session ID.
  • OpenAI Agents SDK conversation state is stored in AsyncDatabricksSession.
  • SDK events are persisted through context.emit() and exposed by developer-authored SSE routes.
  • The approved run includes a 60-second tool call so the process can be stopped and recovered with context.is_recovery=True.
Capability Result
Existing request/response protocol Developer can preserve it
Background execution Runtime primitive provided; HTTP contract developer-owned
Pod/process recovery Supported
Durable stream replay Storage provided; SSE route developer-owned
HITL Two durable runs sharing one session
Final result Stored by the runtime; polling route developer-owned

This prototype makes the cost of the library approach explicit: it has the least protocol coupling and the most developer integration work.

How do you know it works?

  • 23 focused runtime/store tests pass.
  • Ruff check and format pass for the cookbook files.
  • Cookbook modules compile successfully.
  • The OpenAI adapter imports successfully against openai-agents==0.19.4; no live model call was made.

Background and streaming client contract

Concern Contract in this POC
Background The runtime stores and schedules work, but the developer defines 202, run IDs, polling routes, and result mapping.
Streaming context.emit() and runtime.events() provide durable storage; the developer defines SSE, reconnect cursors, and client behavior.
OpenAI Agents SDK client The developer may preserve an existing route or adopt the cookbook's /runs envelope. The library does not mandate the migration.
LangGraph SDK client langgraph_sdk can remain unchanged only if the developer implements its native routes over the runtime; the cookbook instead uses /runs.

The cookbook README includes concrete OpenAI Agents SDK and LangGraph before/after client snippets for background=true, stream=true.

@shivam5

shivam5 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant