TL;DR: Local-only session capture for agent debugging and recovery. Raw outputs never leave the repo. Only metadata is selectively shared.
Session persistence is lightweight simplicity in service of:
NOT designed for: Memory/heap/dump sharing, distributed state sync, or cross-repo broadcasting.
LLM / Agent
↓
wrapper (aido)
↓
PTY (real terminal) + 'script' saves outputs
↓
command execution
Every command that flows through aido captures:
script --quiet --return --commandnexus/.aisessions/SESSION_ID.typescript=== AI_EXIT_CODE: X === marker)nexus/.aisessions/SESSION_ID.meta.jsonnexus/
├── .aisessions/ # Local only, .gitignore'd (NEXUS state database)
│ ├── ai-agent-20260305_132522-3216-2f587606.typescript
│ └── ai-agent-20260305_132522-3216-2f587606.meta.json
│
├── .airuns/ # Future: task/job-level grouping
│ ├── task-20260305_run001/
│ │ ├── session-1.meta.json
│ │ ├── session-2.meta.json
│ │ └── task.status.json # Aggregated task state
│ └── ...
│
└── faults/ # Fault records (part of CODEX LAW 3)
└── ...
{AGENT}-{YYYYMMDD_HHMMSS}-{PID}-{HEXID}
Example: ai-agent-20260305_132522-3216-2f587606
Components:
AGENT: Agent identifier (e.g., ai-agent, claudia, ralph)YYYYMMDD_HHMMSS: Timestamp when session startedPID: Process ID (allows multiple parallel agents)HEXID: Random 6-char hex ID (ensures uniqueness)Benefit: Multiple agents can run in parallel, each with unique session logs.
{
"session_id": "ai-agent-20260305_132522-3216-2f587606",
"agent": "ai-agent",
"timestamp": "2026-03-05T18:25:23Z",
"command": "git status",
"exit_code": 0,
"typescript_file": "./.aisessions/ai-agent-20260305_132522-3216-2f587606.typescript",
"sha256": "81d50ae3d63fe9ec1ea3e223bed3e2a1202a8ba0e289c89ede3c7f802f979d35",
"stdout_tail": "...",
"stderr_head": "...",
"env": {
"SHELL": "/bin/bash",
"OS": "windows",
"REPO_ROOT": "/c/Users/steff/git/.agence"
},
"notes": "...",
"fault": null,
"lessons": [...]
}
Fields:
session_id: Unique identifier for this sessionagent: Which agent ran the commandtimestamp: ISO 8601 UTCcommand: Exact command executed (for re-running)exit_code: MANDATORY - return value of commandtypescript_file: Path to raw I/O logsha256: Hash to verify file integritystdout_tail, stderr_head: Summaries (optional, for quick review)env: Snapshot of execution environment (optional, for debugging)notes: Human-readable summary of what happenedfault: If this session failed, capture fault ID/descriptionlessons: What did we learn? (For CODEX LAW 3).aisessions/SESSION_ID.typescript - Raw terminal output.aisessions/.gitignore entry: .aisessions/SESSION_ID.meta.json with sanitized fields# Example: Export session metadata for handoff
cat .aisessions/ai-agent-20260305_132522-3216-2f587606.meta.json | \
jq 'del(.typescript_file, .stdout_tail, .stderr_head)' > \
/tmp/handoff.json
# Upload to upstream/knowledge-base selectively
curl -X POST https://knowledge-base.internal/sessions \
-d @/tmp/handoff.json
# Session failed (exit_code: 1)
$ cat .aisessions/ai-agent-20260305_132522-3216-2f587606.meta.json | jq '.exit_code'
1
# Read raw output for debugging
$ tail -50 .aisessions/ai-agent-20260305_132522-3216-2f587606.typescript
# Re-run with same command
$ bash bin/aido $(cat .aisessions/ai-agent-20260305_132522-3216-2f587606.meta.json | jq -r '.command')
# Agent A finishes task, captures session
# Agent B needs to continue work
# B reads A's session metadata
$ jq '.notes, .lessons, .fault' < .aisessions/A-session-id.meta.json
# B knows:
# - What A did (notes)
# - Why it failed (fault)
# - What to avoid (lessons)
Every failed session auto-populates:
{
"fault": "f9e7c3d2-symlink-false-success",
"lessons": [
"Truncated output is unreliable - verify filesystem independently",
"VS Code run_in_terminal truncates at ~16KB - use real terminal for long-running tasks",
"Always use 'ls -la' or 'test -e' after claiming success"
]
}
These are stored and queried to prevent recurrence:
# Future sessions check:
if session_has_fault_like("truncation"); then
# Use real terminal, not VSCode
fi
# Default (uses nexus/.aisessions automatically)
bash bin/aido git status
# Override session directory if needed
export AIDO_SESSION_DIR=/custom/path/.aisessions
# Override agent identifier
export AIDO_AGENT=claudia
# Enable debug output
export AIDO_DEBUG=1
# Run wrapped command
bash bin/aido git status
Sessions accumulate over time. Implement circular buffer via cron:
# Cron job (optional, add to ^init later)
0 0 * * * find nexus/.aisessions -type f -mtime +30 -delete # Purge sessions older than 30 days
0 0 * * * ls -t nexus/.aisessions | tail -n +1001 | xargs rm # Keep only last 1000 sessions
.aisessions/ entryVersion: 1.0.0
Status: In Effect (Beta)
Last Updated: 2026-03-05