A bug in Codex's logging system can silently write terabytes of log data to your local SSD, filling disk space and degrading performance. The issue, tracked on GitHub as issue #28224, affects users running Codex in agent mode or with verbose logging enabled. This post explains the root cause, shows you how to check if you're affected, and provides concrete steps to fix and prevent it.
The Bug: What Happens
Codex's logging subsystem, when configured with certain verbosity levels or when running long-lived agent sessions, can enter a loop that writes log entries at an extremely high rate. In some cases, users reported log files growing by 100 GB per hour, eventually consuming terabytes. The logs are written to the default log directory, typically ~/.codex/logs/ on Linux/macOS or %USERPROFILE%\.codex\logs\ on Windows.
How to Check If You Are Affected
-
Check disk usage on the drive where your home directory resides:
bashdu -sh ~/.codex/logs/If this shows tens of gigabytes or more, you are likely affected.
-
Inspect log file sizes:
bashls -lh ~/.codex/logs/Look for files like
codex.log,codex-agent.log, or rotated archives. If any file exceeds 1 GB, that's a red flag. -
Monitor log growth over a short period:
bashwatch -n 10 'du -sh ~/.codex/logs/'If the size increases by more than a few MB per minute, you have the bug.
Root Cause
The bug originates from an infinite loop in the logging handler when Codex's agent mode attempts to log every tool call and response at DEBUG level. In normal operation, these logs are rate-limited or truncated. However, a race condition in the log rotation logic can cause the handler to skip the rate limiter, writing every event as a full JSON blob. The issue is exacerbated when running Codex with --verbose or --debug flags.
Step-by-Step Fix
1. Stop Codex Immediately
If you see high disk usage, stop Codex:
# If running as a service
systemctl stop codex
# Or kill the process
pkill codex
2. Clear Existing Logs
Delete the log directory to free space:
rm -rf ~/.codex/logs/
3. Apply the Configuration Fix
Create or edit ~/.codex/config.yaml to limit log verbosity and size:
logging:
level: "WARN" # Change from DEBUG or INFO
max_size_mb: 100
max_files: 3
disable_agent_logging: true # New flag to prevent agent log spam
4. Restart Codex
codex start
5. Verify Fix
Run Codex normally for a few minutes, then check log size again. It should stay under 100 MB.
Long-Term Prevention
- Never run Codex with
--debugin production. Use--verboseonly when actively debugging a specific issue. - Set log rotation limits in config as shown above. The defaults are too permissive.
- Monitor disk usage with a cron job or systemd timer:
bash
# /etc/cron.hourly/check-codex-logs #!/bin/bash LOG_DIR="$HOME/.codex/logs" if [ -d "$LOG_DIR" ]; then SIZE=$(du -sb "$LOG_DIR" | cut -f1) if [ "$SIZE" -gt 1073741824 ]; then # 1 GB echo "Codex logs exceed 1 GB: $SIZE bytes" | mail -s "Codex Log Alert" you@example.com fi fi - Use a separate disk or partition for logs if you must run verbose logging. Mount a tmpfs or a small SSD partition at
~/.codex/logs.
Tradeoffs
- Disabling agent logging (
disable_agent_logging: true) means you lose visibility into agent tool calls. For debugging agent behavior, you may need to temporarily re-enable it with a lowmax_size_mb. - Setting log level to WARN suppresses INFO messages, which may include useful status updates. Balance verbosity with disk space.
- The bug is fixed in Codex v0.8.3+ (as of the latest release). Upgrade to the latest version to get the official patch. However, the configuration hardening is still recommended.
Keep Reading
- My Agent Skill for Test-Driven Development
- Zero-Touch OAuth for MCP
- Claude Code: Everything You Can Configure That the Docs Don't Tell You
If you need a reliable AI coding assistant without the logging headaches, try Zlyqor: https://app.zlyqor.com/signup

Comments
Have a question or something to add? Sign in to join the discussion.