Overview

Agent sessions are conversation threads backed by the Gizzi runtime on your data-plane node. The public path is on the Cloud API: it authenticates the Clerk session, resolves your default healthy node, and relays the request to Allternit API. Session rows live in that node’s SQLite, not in Cloud API Postgres. The node translates the session contract (/api/v1/agent-sessions) into the Gizzi runtime contract (/v1/session/*). Sessions support messages, abort, revert/unrevert, compaction, ephemeral incognito chats, and real-time event synchronization via SSE.
HTTP 428 means this account has no healthy paired or provisioned node. Pair a desktop/VPS or start a provisioned instance, then retry.

Base URL

Local data plane (same machine only): http://127.0.0.1:8013/api/v1.

Authentication

All production requests must include a Clerk session JWT in the Authorization header. The Cloud API forwards that header to the node. Gizzi-specific Basic auth is handled internally on the node when GIZZI_PASSWORD / GIZZI_SERVER_PASSWORD is configured.

Session object

Endpoints

List sessions

Returns sessions owned by the caller, filtered and searched on the gateway side. Ephemeral sessions are excluded from the list.

Query parameters

Example request

Example response

Create a session

Creates a new Gizzi session. The gateway stamps the model (the request’s model, else the bound agent’s saved brain, else the user’s chosen default), resolves the agent harness config, and records the original surface so it can be restored later. There is no default model: when none of these is set the session is created without one, and its first turn answers 409 no_brain.

Request body

Example request

Example response

The surface design is normalized to chat for Gizzi compatibility; the original value is preserved in metadata.originSurface.

Plain chats on a picked runtime

A plain chat created with metadata.botBrain or metadata.runtime naming a runtime other than allternit runs on that runtime, the way a bot with a native-harness brain does. The gateway checks the pick, stores the normalized botBrain and runtime on the session, and runs every turn on the runtime CLI’s provider (for Claude Code, claude-cli/<model>). A turn’s model is kept when that CLI runs it. Otherwise the turn uses the session brain’s model, and if that does not fit, the CLI’s default model. The session never falls back to the default runtime without telling you. The 422 checks run only when the request names runtime itself (in botBrain or metadata.runtime). The brain checked is botBrain.modelRef, else the request’s model. Show message to the user as it is.

Get a session

Example request

Example response

Same shape as the create response.

Update a session

Updates the session title, archived state, permission, or surface.

Request body

Changing a plain chat’s runtime

When an update to a plain chat (not a bot or agent session) carries metadata.runtime or metadata.botBrain, and the runtime or the brain (modelRef) differs from what the session stores, the gateway runs the same checks as create before it changes anything. It returns the same 422 (runtime_unknown, brain_not_fit, plan_not_allowed_on_runtime) and 409 runtime_not_installed bodies. If the checks pass, it stores the new runtime and normalized botBrain, and the next turn runs on the new runtime’s CLI. The old runtime’s agent_session is dropped unless the new brain names a nativeSessionId. Moving to allternit stores runtime: "allternit", and turns go back to the default path. An update that sends back the same runtime and brain (for example the whole bag) is not checked. Bot and agent sessions are never checked or moved this way. | markReviewed | boolean | true clears readyForReview. Clients send it when the user opens a session. |

Session status flags

The server keeps two status flags in metadata and returns them on every session read. A missing key means false. Clients can’t set or clear them through metadata. Rules:
  • needsInput turns on when the runtime asks for permission or asks a question. It turns off when the last open ask of that session is answered or dismissed, when the run errors or ends, and when a new run starts.
  • readyForReview turns on when a run ends after a file write or edit (the file.edited runtime event) or a completed artifact_create / artifact_update tool call. It turns off when a new run starts or a client sends markReviewed: true.
  • The API server watches the runtime’s event stream all the time, so the flags change while no app is open. Each change is also sent on the sync stream as session_flags.

Example request

Example response

Same shape as the create response, with active: false.

Delete a session

Deletes the backing Gizzi session and clears any local ephemeral flag.

Example response

204 No Content

List messages

Returns the session’s messages in gateway-normalized form.

Example response

Send a message

Sends a message to the session. role: "user" messages are forwarded to the runtime. role: "assistant" with noReply: true stores a static assistant message without a model turn (a bot’s greeting in its new main chat); it is labelled with metadata.source and stored once per session and source, however many clients post it. Other roles are accepted locally and echoed back immediately.

Request body

In a plain chat created on a runtime, the turn runs on that runtime’s CLI (see Plain chats on a picked runtime). Otherwise the turn runs on metadata.model, else the user’s chosen default, else (in a bot’s thread) the thread’s or the bot’s saved brain. With none of these, the call returns 409 {"error":"no_brain","message":"Pick a brain first."} and nothing is sent. A noReply message needs no brain.

Example request

Example response

Same shape as a message from list messages.

List earlier versions

When you edit a message or retry, the replaced turns are kept as branches. This returns them newest first, at most 20. The gizzi runtime serves the same list at GET /v1/session/:sessionID/branches.

Example response

anchorMessageId is the message the edit or retry started from. messages has the same shape as List messages. Large inline attachments are stored without their data.

Abort a session

Aborts the current turn. For ephemeral sessions, this also hard-deletes the backing session and clears the ephemeral flag.

Example response

Revert a session

Reverts file changes made during the session back to a given message.

Request body

Example response

Same shape as get session.

Unrevert a session

Undoes a prior revert.

Example response

Same shape as get session.

Compact a session

On-demand context condensation via Gizzi’s summarize endpoint.

Example response

Sync sessions (SSE)

Opens a server-sent event stream that forwards Gizzi bus events in a frontend-friendly shape. Supports Last-Event-ID reconnection.

Supported event types

Linked pull requests

GitHub pull requests a code session created or pushed to, or that were linked by hand. Each item is a LinkedPR: Statuses are cached for at least a minute and refresh in the background; changes arrive on the sync stream as session_prs.

Example curl

Example event

Additional routes

These routes are registered by the same router on the Allternit API node. See the code in cmd/allternit-api/src/agent_session_routes.rs for request shapes.

Error codes