Build profiles
| Profile | Cargo Features | Use Case |
|---|---|---|
| Minimal | --no-default-features | Ephemeral agent, no persistence, no compaction |
| Persistent | session-store | Sessions survive restart, redb-backed storage |
| Compacting | session-compaction | Auto-compact long conversations |
| Full | session-store,session-compaction | Persistent + compacting |
Capability behavior
| Operation | Minimal | Persistent | Compacting | Full |
|---|---|---|---|---|
create_session | Works | Works | Works | Works |
start_turn | Works | Works + snapshot saved | Works | Works + snapshot saved |
interrupt | Works | Works | Works | Works |
read (live session) | Works | Works | Works | Works |
read (archived) | SESSION_NOT_FOUND | Falls back to store | SESSION_NOT_FOUND | Falls back to store |
list | Live sessions only | Live + stored sessions | Live sessions only | Live + stored sessions |
archive | Removes from memory | Removes from memory, snapshot kept | Removes from memory | Removes + snapshot kept |
| Auto-compaction | No-op | No-op | Triggers at threshold | Triggers at threshold |
Error codes
Deterministic error codes across all surfaces. EverySessionError variant maps to a stable
string code and a transport-specific representation:
SessionError | Code | JSON-RPC | REST | MCP | CLI |
|---|---|---|---|---|---|
NotFound | SESSION_NOT_FOUND | -32001 | 404 | tool error | exit 1 |
Busy | SESSION_BUSY | -32002 | 409 | tool error | exit 1 |
PersistenceDisabled | SESSION_PERSISTENCE_DISABLED | -32003 | 501 | tool error | stderr |
CompactionDisabled | SESSION_COMPACTION_DISABLED | -32004 | 501 | tool error | stderr |
NotRunning | SESSION_NOT_RUNNING | -32005 | 409 | tool error | exit 1 |
Store | SESSION_STORE_ERROR | -32000 | 500 | tool error | exit 1 |
Agent | AGENT_ERROR | -32000 | 500 | tool error | exit 1 |
Transport error mapping summary
- JSON-RPC: Custom error codes in the -32000..-32099 range. The
codefield of the JSON-RPC error object carries the string code (e.g.SESSION_NOT_FOUND). - REST: HTTP status codes (404, 409, 500, 501). Error body includes
{ "code": "...", "message": "..." }. - MCP Server: Tool calls return
is_error: truewith the error message and code in the content. - CLI: Non-zero exit codes.
exit 1for errors,exit 2for budget exhaustion. Error details printed to stderr.
Pick only what you need
Compaction behavior
Whensession-compaction is enabled:
- Trigger:
last_input_tokens >= thresholdORestimated_history_tokens >= threshold - Guards: Never on first turn. Minimum 3 turns between compactions.
- Failure: Non-fatal.
CompactionFailedevent emitted, agent continues with uncompacted history. - Budget: Compaction LLM call draws from the same token budget as regular turns.
CompactionStarted, CompactionCompleted, CompactionFailed.
Concurrency
- At most one turn runs per session at a time.
- Second
start_turnwhile one is in-flight returnsSESSION_BUSY. interrupt()cancels the in-flight turn.read()andlist()are non-blocking.- No queueing: callers retry on
Busy.
Durability
- Ephemeral: Process death loses all state.
- Persistent: Snapshot saved AFTER turn completes. Crash mid-turn loses the in-flight turn.
.rkat/sessions/files are derived (projected) output, not canonical source. Deleting them and replaying from the event store produces identical content.
See also
- Session contracts — concurrency, durability, and compaction semantics
- Architecture — crate structure and agent loop details
