A session is a single, isolated execution of an agent. When you create a session, the platform boots a Kubernetes sandbox pod, clones the agent’s configured repository, injects environment variables, and starts the harness process. The session lives until it is explicitly deleted or until it has been idle for 24 hours, at which point the reconciler reaps it automatically.Documentation Index
Fetch the complete documentation index at: https://docs.litellm-agent-platform.ai/llms.txt
Use this file to discover all available pages before exploring further.
Session lifecycle
Every session moves through a status field that reflects its coarse state.creating
The platform has accepted the request and is provisioning the sandbox pod. This state covers everything from pod scheduling through harness startup.
ready
The harness is running and accepting work. For API harnesses, you can send messages via
POST /sessions/{id}/message. For TUI harnesses, you can attach a terminal via lap or the browser.dead
The session ended cleanly — either you deleted it, or the idle timeout elapsed and the reconciler reaped it.
Bring-up phases
While a session’sstatus is creating, the phase field gives you fine-grained visibility into exactly where in the startup sequence it is. The platform owns the first six phases; the harness inside the sandbox reports the last three.
| Phase | Owner | What is happening |
|---|---|---|
creating_sandbox | Platform | Sandbox CR is being submitted to Kubernetes. |
pod_pending | Platform | Pod is scheduled but containers have not started yet. |
pod_running | Platform | All containers are running; waiting for the harness HTTP endpoint to respond. |
injecting_files | Platform | Sandbox files from the agent configuration are being written into the container. |
waiting_harness | Platform | HTTP health probe is polling the harness until it accepts connections. |
harness_ready | Platform | Harness HTTP endpoint responded; the platform can now create the harness session. |
cloning_repo | Harness | Harness is running git clone for the configured repo_url. |
installing_deps | Harness | Harness is installing packages from AGENT_REQUIREMENTS. |
harness_listening | Harness | Harness process is fully initialized and ready to accept the first message. |
ready | — | Session status flips to ready. |
The
phase_detail field carries an optional human-readable subtitle for the current phase. The web UI renders it below the active step in the spawn-progress card.Session fields
The API returns sessions asApiSession objects.
| Field | Type | Description |
|---|---|---|
id | string | Unique session identifier. |
agent_id | string | The agent this session belongs to. |
status | string | Coarse lifecycle state: creating, ready, dead, or failed. |
phase | string | null | Fine-grained bring-up phase (see table above). null on sessions created before the phase column existed. |
phase_detail | string | null | Optional subtitle for the current phase. |
sandbox_url | string | null | Cluster-internal HTTP URL for the harness. null until the pod is running. |
tty_url | string | null | Browser-accessible WebSocket base URL for TUI harnesses. null for API harnesses and during startup. |
tty_token | string | null | Bearer token for the harness /tty WebSocket. Passed as ?token=… by lap and the browser terminal. |
response | object | null | Latest harness reply blob. Populated after the first message. |
last_seen_at | string | null | ISO 8601 timestamp of the last POST /message. null until the first message. |
idle_timeout_ms | number | Milliseconds of inactivity after which the reconciler reaps a ready session. Currently 86,400,000 ms (24 hours). |
failure_reason | string | null | Human-readable reason why status flipped to failed. |
created_at | string | ISO 8601 creation timestamp. |
Creating a session
initial_prompt is optional. Omit it to bring up the sandbox without sending any message — useful when you want to attach a TUI terminal and drive the agent interactively.
Per-session env vars
Passenv_vars when creating a session to inject short-lived secrets into the sandbox at launch time. These are forwarded directly into the container environment and are never persisted to the database and never logged by value.
Constraints
All of the following are enforced atPOST /session time. Any violation returns 400.
- Maximum 50 keys.
- Total JSON-encoded size ≤ 16 KB.
- Key names must match
^[A-Za-z_][A-Za-z0-9_]*$. - Keys cannot overlap the reserved set.
env_vars when the same key appears in both.
Idle timeout and session reaping
Aready session that receives no POST /message traffic for 24 hours is automatically stopped by the background reconciler. The session status flips to dead and the sandbox pod is deleted.
The idle_timeout_ms field in the session response carries the exact threshold so the UI can show an accurate countdown. The countdown resets on every POST /message.
Press Ctrl-D in the lap CLI to detach from a TUI session without stopping it. The session stays alive and you can reconnect by running lap <agent-name> again.