Session lifecycle management, persistence, resumption, and event tracking in ScorpioX Code. Every conversation is a session with structured logging, hooks, and configurable retention.
Every ScorpioX Code conversation is a session. Sessions are managed by sx_session.c in libsxutil, providing persistence, structured event logging, and hook-based extensibility. Sessions are stored on disk as directories under .scorpiox/sessions/<id>/, each containing conversation state, event logs, and metadata.
The session system integrates with the TUI resume picker (sxui_resume in libsxui) for selecting and continuing previous sessions, and with scorpiox-tmux for terminal multiplexer session management.
A session moves through well-defined stages. Each transition fires the corresponding hook, allowing you to inject custom logic at every step.
Agent recursion within a session is bounded by AGENT_MAX_RECURSION_DEPTH (default: 10). Each sub-agent invocation increments the depth counter, preventing runaway nested calls.
Session data is stored on disk in the project's .scorpiox/ directory. Each session gets a unique ID-based directory:
Events are written as JSONL (JSON Lines) to events.jsonl via sx_session_event(). When EMIT_SESSION_TRACKING is enabled, events are also emitted as individual msg_NNNN_event.json files for SDK consumers.
All session settings are configured via scorpiox-env.txt in your project root or ~/.scorpiox/. These keys control session behavior, timeouts, and logging.
| Key | Default | Description | Source |
|---|---|---|---|
AGENTLESS_MODE |
0 |
Run in agentless mode (no sub-agents) | sx_config.c |
AGENT_MAX_RECURSION_DEPTH |
10 |
Maximum recursion depth for nested agent calls | sx_agent.c |
ASKUSER_TIMEOUT |
120 |
Timeout in seconds for AskUserQuestion prompts | sx_agent.c |
AUTO_ACCEPT_PLAN |
1 |
Auto-accept plans without user confirmation | sx_state.c |
BASH_DEFAULT_TIMEOUT |
30000 |
Default timeout in ms for Bash tool execution | sx_agent.c |
BASH_MIN_TIMEOUT |
0 |
Minimum timeout in ms for Bash tool (0 = no minimum) | sx_agent.c |
LOG_DIR |
.scorpiox/logs |
Directory for session logs | sx_config.c |
LOG_LEVEL |
INFO |
Logging verbosity (DEBUG, INFO, WARN, ERROR, TRACE) | sx_config.c |
PROJECT_DIR |
— |
Project directory override for CLAUDE.md search | scorpiox-email.c |
SESSION_RETENTION_DAYS |
7 |
Days to retain session logs | sx_config.c |
Session lifecycle hooks let you run shell scripts at key moments. Place executable scripts in the corresponding .scorpiox/hooks/ subdirectory. Scripts prefixed with sync- run synchronously (blocking); all others run async.
When enabled, ScorpioX Code emits structured session events that can be consumed by external systems for analytics, billing, or audit trails.
| Key | Default | Description |
|---|---|---|
EMIT_SESSION_API_URL |
— |
API endpoint for session event data |
EMIT_SESSION_TRACKING |
0 |
Enable session event emission |
USAGE_API_URL |
— |
API endpoint for usage tracking data |
USAGE_TRACKING |
0 |
Enable usage/telemetry tracking |
The event function signature in C: sx_session_event(SxSession *s, const char *event, const char *json_fields) — appends a timestamped JSON line to the session's event log.
ScorpioX Code can resume previous sessions via the TUI session picker. The sxui_resume component in libsxui presents a list of recent sessions with metadata (model, timestamp, turn count) and lets you continue where you left off.
Session retention is controlled by SESSION_RETENTION_DAYS (default: 7). Sessions older than this are automatically cleaned up on next launch.
Session-related CLI flags and slash commands: