Skip to content
Konstera
Docs · Build agents
Konstera documentation.

Getting started, SDK quickstart, manifest reference, kernel MCP services, deploy guide and FAQ — everything you need to build and run agents on Konstera.

Why Temporal

Every Konstera agent invocation — sync HTTP, async queue, cron, webhook, child workflow, HiL — is a Temporal workflow. This is unusual (most agent platforms don't have a workflow engine) and it was a deliberate choice (ADR-002).

Here's what we got for it, and what we gave up.

The alternatives we rejected#

Option A: raw HTTP + retry middleware. Fine for sync invocations. Doesn't handle cron, doesn't survive a container crash mid-invocation, doesn't give you replay for debugging.

Option B: a message queue (SQS, RabbitMQ) + workers. Handles async + cron. Doesn't give you per-invocation durability (the queue is at-least- once, not exactly-once). Doesn't give you signals for human-in-the-loop. Debug replay is hand-rolled.

Option C: Temporal. All of the above + mature primitives for long-running workflows with human-in-the-loop. Our ambition is agents that pause for days waiting on a reviewer; option C handles that; options A and B don't.

What Temporal gives us#

Durable execution#

If an agent container crashes mid-handle, Temporal replays the workflow on a new container. Every await ctx.* call is memoised in the workflow history — on replay, the kernel returns the same result it returned the first time. The agent's handle() continues from where it left off.

Concretely: if your agent crashed just after await ctx.llm.complete(...) and before returning, the replay doesn't re-call the LLM. The LLM response is retrieved from history, and handle() resumes.

At-least-once with memoisation = effectively exactly-once#

Temporal activities are at-least-once; retries can fire. But every kernel-side activity (log, llm, state, etc.) checks the workflow history first — if this call was already executed in a prior attempt, it returns the cached result instead of re-executing.

For the agent, this means idempotency is handled for you on all SDK calls. The one place to be careful is inside your agent code — if you call an external API directly (not via ctx.*), it's your responsibility to dedupe. The platform's advice: always route via ctx.capability.* or ctx.connector.* so the kernel's memoisation applies.

Human-in-the-loop via signals#

An approval request parks the workflow:

Python
decision = await ctx.human.request(kind="refund", tier="T1", summary="...")

Under the hood, this is a Temporal signal wait. The workflow sleeps — no container running, no memory held — until the kernel receives a signal (reviewer clicked approve/reject). Then the workflow wakes up, decision is populated, handle() resumes.

This works across:

  • Minutes (reviewer online)
  • Hours (overnight approvals)
  • Days (reviewer out, waits in inbox)
  • Container restarts (platform upgrade mid-wait)
  • Full stack upgrades (as long as the Temporal cluster stays)

Replay for root-cause analysis#

Any invocation can be replayed from its history:

Terminal
konstera invocation replay inv-abc123 --to-agent-version 0.9.3-draft

The replay feeds the same req to a different agent version. All kernel calls return their original results (from history). You see your new code's reaction to the same inputs — perfect for validating a bug fix.

See Debugging failed invocations for the full workflow.

Timeouts + retry policies at the primitive level#

Manifest retryPolicy becomes a Temporal activity policy:

JSON
"retryPolicy": {
  "maxAttempts": 3,
  "backoffSeconds": 10,
  "backoffMultiplier": 2.0
}

Temporal enforces this per activity (each ctx.* call is an activity). Your handle() doesn't write retry loops — the primitives already have them.

What we gave up#

Determinism constraint#

A Temporal workflow must be deterministic — on replay, the same inputs must produce the same calls in the same order. Your handle() is the workflow; so:

  • No non-determinism: don't call random.randint(), datetime.now(), uuid4() directly. Use ctx.tool.call("datetime_now") / ctx.tool.call("uuid_new") — they're activities, their results memo.
  • No direct I/O: don't open files, don't requests.get(...), don't open DB connections. Go via ctx.*.
  • No in-memory state between invocations: use ctx.state.

The SDK is designed to make these the natural path. If you follow the "use ctx.* for everything that touches the outside world" rule, you'll never trip the determinism check.

Operational complexity#

Temporal is a cluster — frontend, matching, history, worker services + PostgreSQL (two DBs: main + visibility) + Elasticsearch (optional). Not trivial to run.

In managed Cloud, Konstera runs this for you. In self-hosted, the Helm chart ships Temporal as a dependency with sensible defaults; you can externalise it to Temporal Cloud or your own cluster if you'd rather.

Startup latency#

Temporal workflows have a cold-start cost of ~50–200ms (vs. a bare HTTP handler at <10ms). For sync HTTP invocations this is noticeable; for async / cron / webhook / HiL it's irrelevant.

The latency isn't the agent's handle() — it's the workflow scheduling

  • dispatch. For latency-sensitive endpoints, consider whether the operation really needs full durability (if not, the kernel exposes a lightweight non-workflow HTTP path for a narrow set of use cases).

Hidden implementation detail#

Temporal is not visible to tenant users. The portal's "invocation inspector" is a Konstera-native UI backed by invocations + invocation_logs tables; the raw Temporal UI is admin-only at /admin/workflows and uses platform-admin permissions.

The words "workflow" and "task queue" don't appear in tenant-user copy — users see "invocations" and "runs." See ADR-006 if you're curious why.

See also#