Skip to content

Instantly share code, notes, and snippets.

@Lysak
Last active June 23, 2026 06:12
Show Gist options
  • Select an option

  • Save Lysak/f3aebb1675758d38f4f3ec20898d6632 to your computer and use it in GitHub Desktop.

Select an option

Save Lysak/f3aebb1675758d38f4f3ec20898d6632 to your computer and use it in GitHub Desktop.
Fix: Codex SQLite logs ~640 TB/year SSD write issue (openai/codex#28224) - aka fix codex ssd issue

Fix: Codex SQLite logs ~640 TB/year SSD write issue

Fixes openai/codex#28224.

Codex writes millions of TRACE-level rows per day to ~/.codex/logs_2.sqlite via insert-and-prune churn, rapidly consuming SSD write endurance.

Files

  • block-logs-trigger.sh — watcher script
  • com.codex.block-logs-trigger.plist — macOS LaunchAgent

How it works

The script installs a SQLite trigger that silently drops all INSERT operations on the logs table. The LaunchAgent watches ~/.codex/ via WatchPaths and re-applies the trigger automatically if Codex recreates the database.

Instructions for AI agent

  1. Determine the user's home directory path (e.g. /Users/username)
  2. Save block-logs-trigger.sh to ~/.codex/block-logs-trigger.sh and run chmod +x on it
  3. Save com.codex.block-logs-trigger.plist to ~/Library/LaunchAgents/com.codex.block-logs-trigger.plist, replacing all occurrences of PLACEHOLDER_HOME with the actual home directory path
  4. Run launchctl load ~/Library/LaunchAgents/com.codex.block-logs-trigger.plist
  5. Run bash ~/.codex/block-logs-trigger.sh to apply the SQLite trigger immediately
#!/bin/bash
DB="$HOME/.codex/logs_2.sqlite"
[ -f "$DB" ] || exit 0
TRIGGER=$(sqlite3 "$DB" "SELECT name FROM sqlite_master WHERE type='trigger' AND name='block_log_inserts' LIMIT 1;" 2>/dev/null)
[ "$TRIGGER" = "block_log_inserts" ] && exit 0
sqlite3 "$DB" "CREATE TRIGGER IF NOT EXISTS block_log_inserts BEFORE INSERT ON logs BEGIN SELECT RAISE(IGNORE); END;" 2>/dev/null
echo "$(date '+%Y-%m-%d %H:%M:%S') block_log_inserts trigger applied to $DB"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.codex.block-logs-trigger</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>PLACEHOLDER_HOME/.codex/block-logs-trigger.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>PLACEHOLDER_HOME/.codex</string>
</array>
<key>StandardOutPath</key>
<string>PLACEHOLDER_HOME/.codex/block-logs-trigger.log</string>
<key>StandardErrorPath</key>
<string>PLACEHOLDER_HOME/.codex/block-logs-trigger.log</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment