How to Build with Codex: Avoiding the Logging Bug That Writes TBs to Local SSDs

A logging bug in Codex can write terabytes of logs to your local SSD. Here's how to detect, fix, and prevent it with practical steps and configuration changes.

Mahmudul Haque Qudrati — CEO & ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & ML Engineer

June 23, 2026
3 min read
How to Build with Codex: Avoiding the Logging Bug That Writes TBs to Local SSDs

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

  1. Check disk usage on the drive where your home directory resides:

    bash
    du -sh ~/.codex/logs/
    

    If this shows tens of gigabytes or more, you are likely affected.

  2. Inspect log file sizes:

    bash
    ls -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.

  3. Monitor log growth over a short period:

    bash
    watch -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:

bash
# 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:

bash
rm -rf ~/.codex/logs/

3. Apply the Configuration Fix

Create or edit ~/.codex/config.yaml to limit log verbosity and size:

yaml
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

bash
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 --debug in production. Use --verbose only 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 low max_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

If you need a reliable AI coding assistant without the logging headaches, try Zlyqor: https://app.zlyqor.com/signup

Frequently Asked Questions

What is the Codex logging bug that writes TBs to local SSDs?

It's a bug in OpenAI Codex where the logging subsystem can enter an infinite loop, writing log entries at a very high rate. This can fill up your local SSD with terabytes of log files, especially when running in agent mode or with verbose logging enabled.

How do I check if my Codex installation is affected by the logging bug?

Run `du -sh ~/.codex/logs/` to see the total log size. If it's several gigabytes or more, you are likely affected. Also monitor growth with `watch -n 10 'du -sh ~/.codex/logs/'` , if it increases by more than a few MB per minute, you have the bug.

How can I fix the Codex logging bug?

Stop Codex, delete the log directory (`rm -rf ~/.codex/logs/`), then edit `~/.codex/config.yaml` to set `logging.level: WARN`, `logging.max_size_mb: 100`, `logging.max_files: 3`, and `logging.disable_agent_logging: true`. Restart Codex. Upgrade to Codex v0.8.3+ for the official fix.

What are the best practices for configuring Codex logging?

Set log level to WARN in production, limit max log size to 100 MB and keep only 3 rotated files. Disable agent logging unless needed. Monitor disk usage with a cron job. Use a separate partition or tmpfs for logs if you need verbose logging.

How much does Codex cost?

Codex is available through OpenAI's API with usage-based pricing. As of 2026, it costs $0.15 per 1K input tokens and $0.60 per 1K output tokens for the latest model. There is no fixed monthly fee, but you pay for what you use.

Is Codex worth using in 2026?

Codex remains a powerful tool for AI-assisted coding, especially for complex multi-step tasks. However, the logging bug and other issues mean you must invest time in configuration and monitoring. Alternatives like Zlyqor offer similar capabilities with more predictable behavior and built-in safeguards.

#codex#logging-bug#ssd#disk-space#configuration#debugging#agent-mode

One AI engineering post, weekly

LLM benchmarks, prompt techniques, and token-cost breakdowns, delivered to your inbox.

Comments

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

Mahmudul Haque Qudrati — CEO & ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & ML Engineer

Visionary technologist, software engineer, and machine learning specialist. Founder and CEO of Pristren, directing engineering teams that ship production-grade AI/ML pipelines, mission-critical full-stack applications, and developer tooling. Creator of Zlyqor, the unified team workspace platform. Author of 540+ technical guides and benchmark research reports on large language models, agentic workflows, Model Context Protocol (MCP), and modern web stacks.

PristrenZlyqor