keelgate.adapters.temporal¶
Stability of each symbol (stable or provisional) is listed in the API contract. Narrative and semantics are in the integration contract.
Temporal adapter: run a Keelgate loop as a Temporal workflow (keelgate[temporal]).
Temporal supplies what the default LangGraph-style checkpointing cannot: a durable driver. If the
worker dies mid-run, Temporal re-runs the activity on another worker. That is safe because the
activity calls Loop.run_or_resume, which loads the loop's own checkpoint and never repeats a
completed WRITE (idempotency keys), and never auto-retries a WRITE whose outcome is unknown.
Division of labour:
- the workflow is deterministic orchestration only: one activity, a retry policy, a timeout;
- the activity does all the real work (model calls, tool calls) through the governed gateway;
- the loop's checkpoint store must be shared between workers (SQLite on a shared volume, or a database), because that is how a replacement worker resumes.
A stop for budget or approval is a normal result (resumable=True), not an activity failure,
so Temporal does not retry it.
KeelgateLoopWorkflow
¶
A Temporal workflow that runs one loop as an activity.
A retried attempt resumes from the loop's checkpoint rather than starting over.
LoopActivities
¶
The activity implementation. loop_factory builds the loop on the worker.
TemporalRunner
¶
A :class:~keelgate.loop._runner.LoopRunner that starts the loop as a Temporal workflow.
The workflow id is derived from the tenant and run id, so starting the same run twice attaches to the existing workflow instead of creating a second one.
WorkflowOptions
dataclass
¶
Timeouts and retries for the loop activity.
build_worker
¶
build_worker(
client: Client,
loop_factory: Callable[[], Loop],
*,
task_queue: str = DEFAULT_TASK_QUEUE,
**worker_kwargs: Any,
) -> Worker
A worker serving the loop workflow and its activity.