nca persists every conversation as a session. Sessions can be resumed, inspected, attached to, and managed through the CLI.
nca (start) → Session Created → Agent Turns → Session Ended
↓ ↓
.nca/sessions/<id>.json .nca/sessions/<id>.events.jsonl
↓ ↓
State snapshot Full event log
| Status | Description |
|---|---|
running |
Session is currently active |
completed |
Session finished successfully |
cancelled |
Session was cancelled by the user |
failed |
Session ended with an error |
Sessions are stored in the workspace under .nca/sessions/:
.nca/sessions/
├── a1b2c3d4.json # Session state snapshot
├── a1b2c3d4.events.jsonl # Event log (NDJSON)
├── e5f6g7h8.json
├── e5f6g7h8.events.jsonl
└── ...
Contains session metadata:
- Session ID and timestamps (created, updated)
- Workspace path and working directory
- Model and provider configuration
- Session status and PID
- Socket path for IPC
- Parent/child session relationships
- Session summary
- Git branch information
- Worktree path (for sub-agent sessions)
Append-only NDJSON log of every event in the session:
- Messages sent and received
- Token usage and streaming events
- Tool call starts and completions
- Approval requests and resolutions
- Child session spawns and completions
- Context warnings and compaction events
- Errors and status changes
Each event has a monotonic id and ts (timestamp).
nca sessions # List recent sessions (default: 20)
nca sessions --limit 50 # Show more
nca sessions --status running # Filter by status
nca sessions --since-hours 24 # Last 24 hours
nca sessions --search "auth" # Search by content
nca sessions --json # JSON outputResume picks up a session with full conversation context:
# Resume by ID
nca resume <session-id>
# Resume with a follow-up prompt
nca resume <session-id> --prompt "continue with the tests"
# Resume with a different model
nca resume <session-id> --model "claude-3-7-sonnet-latest"
# Resume the most recent session (shorthand)
nca -r
nca --resumeBy default, when you run nca without any arguments:
- nca checks
.nca/.last_sessionfor the most recent session ID - If a valid recent session exists, nca auto-resumes it with a hint to stderr
- If no valid session exists, a new session starts
Override this:
nca --no-resume # Always start fresh
nca --resume # Always resume last sessionnca logs <session-id> # Dump event log
nca logs <session-id> --follow # Stream in real-time
nca logs <session-id> --json # Raw JSON eventsnca attach <session-id> # Attach to output stream
nca attach <session-id> --json # JSON event streamnca status <session-id> # Show metadata
nca status <session-id> --json # JSON outputnca cancel <session-id>In the TUI, use /sessions to open a session picker or press Ctrl+X L:
/sessions # Open session picker
/new # Start a new session
As conversations grow, nca can summarize and compact the context to stay within the model's context window:
/compact # Manually compact context
Automatic compaction is controlled by:
[memory.context]
auto_summarize_threshold = 75 # Trigger at 75% of context window
enable_auto_summarize = true
max_retained_messages = 50When auto-summarize triggers, nca:
- Emits a
ContextWarningevent - Summarizes the conversation history
- Replaces older messages with the summary
- Emits a
ContextCompactionevent
Sessions are checkpointed periodically to prevent data loss:
[session]
checkpoint_interval = 5 # Save every 5 turnsExport a session to markdown:
/export
[session]
history_dir = ".nca/sessions" # Where sessions are stored
max_turns_per_run = 128 # Max turns before session ends
max_tool_calls_per_turn = 200 # Max tools per single turn
checkpoint_interval = 5 # Checkpoint frequency
last_session_file = ".nca/.last_session" # Last session pointer
auto_compact_on_finish = false # Summarize on session endUse nca spawn to create sessions that run in the background:
nca spawn --prompt "refactor the auth module"Spawned sessions:
- Run without interactive input
- Default to
accept-editspermission mode - Can be monitored with
nca logs,nca attach,nca status - Can be cancelled with
nca cancel
Running sessions expose a Unix domain socket for real-time event streaming and control:
$XDG_RUNTIME_DIR/nca/<session-id>.sock
# or
/tmp/nca/<session-id>.sock
The IPC protocol uses newline-delimited JSON:
Events (session → client): EventEnvelope objects containing AgentEvent variants.
Commands (client → session):
SendMessage— send a user messageApproveToolCall— approve a pending tool callDenyToolCall— deny a pending tool callAnswerQuestion— answer an agent questionCancel— cancel the current operationShutdown— shut down the session
This enables building external UIs, monitoring dashboards, and automation scripts that interact with running sessions.
When the agent spawns sub-agents, a parent-child relationship is tracked:
- Parent session records child session IDs
- Child session records parent session ID and inherited summary
- The spawn reason is stored in child metadata
- Child sessions can optionally run in isolated git worktrees
View child sessions:
/agents # List child sessions in interactive mode
nca sessions --search "child" # Search for sub-agent sessions