SafeDisk AI

AI agent storage incident

OpenClaw Codex logs_2.sqlite Taking Disk Space

If an OpenClaw-managed Codex home grows through logs_2.sqlite, logs_2.sqlite-wal, or trace rows, treat it as trace retention first. Measure the database, preserve enough evidence, and avoid deleting session state or auth data while a gateway or app-server process is still using the files.

AI storage deletion judgment

Find what the AI tool can delete.

Copy the read-only check first. If the output still needs judgment, leave your email and we send the free SafeDisk AI deletion trial step only when the agent cache or session state needs review.

Add command output optional

Free trial step. We reply first with a delete / confirm / protect judgment or one read-only detail we still need.

See sample result Ask AI about one file
Download free Mac scan Ask free AI judgment

What Is Usually Happening

OpenClaw can run Codex with a managed CODEX_HOME. In long-lived agent or gateway setups, trace storage may grow separately from user-visible sessions. A large logs_2.sqlite can be diagnostic evidence, but it can also become routine storage pressure if there is no retention policy.

Read-only first pass

Measure trace storage without reading private log contents.

These commands report sizes and counts. They do not print prompts, file contents, or log rows.

base="$HOME/.openclaw/agents/main/agent/codex-home"

du -sh "$base" "$base"/logs_2.sqlite* 2>/dev/null
find "$HOME/.openclaw" -name 'logs_2.sqlite*' -print0 2>/dev/null \
  | xargs -0 du -h 2>/dev/null | sort -h

sqlite3 "$base/logs_2.sqlite" 'select count(*) from logs;' 2>/dev/null
sqlite3 "$base/logs_2.sqlite" \
  'select level, count(*) from logs group by level order by count(*) desc;' 2>/dev/null
sqlite3 "$base/logs_2.sqlite" \
  'select target, count(*) from logs group by target order by count(*) desc limit 20;' 2>/dev/null

lsof -nP "$base"/logs_2.sqlite* 2>/dev/null

Safe Recovery Order

  1. Stop starting new OpenClaw or Codex work while the filesystem is close to full.
  2. Capture the read-only size, row count, target distribution, and current writer process.
  3. Stop the OpenClaw gateway or managed Codex app-server cleanly before moving SQLite files.
  4. Move logs_2.sqlite* into a timestamped backup folder instead of deleting immediately.
  5. Restart OpenClaw, verify turns still work, then compress or remove the backup after you no longer need evidence.
  6. Add a retention job or alert so the same trace DB does not silently regrow.
Move, do not blind-delete

Use this only after the gateway/app-server is stopped.

This preserves a rollback path and keeps session JSONL/state files outside the cleanup target.

base="$HOME/.openclaw/agents/main/agent/codex-home"
backup="$HOME/.Trash/SafeDisk-OpenClaw-Codex-logs-$(date +%Y%m%d-%H%M%S)"

mkdir -p "$backup"
for file in "$base"/logs_2.sqlite "$base"/logs_2.sqlite-wal "$base"/logs_2.sqlite-shm; do
  [ -e "$file" ] || continue
  mv "$file" "$backup"/
done

du -sh "$backup" 2>/dev/null
echo "Restart OpenClaw, verify one turn, then decide whether to compress or delete this backup."

Do Not Delete First

Free AI deletion trial

Need a delete / confirm / protect answer for AI tool files?

Submit the form first; the command output or one-line agent storage symptom can follow. We check whether free guidance is enough before asking for the free SafeDisk AI deletion trial.

Add output optional

Start with email. Output can follow after the first reply.