If you run long tasks with the Codex CLI, you know the moment. You leave a refactor running, come back an hour later, and find the session stopped halfway because you hit the usage limit. Now you have to work out when the 5-hour window resets, come back at the right time, and type "continue" yourself. If the weekly limit ran out, the wait can last days, even though your account may hold reset credits that quietly expire unused. This happened to me often enough that I built a small, free and open-source macOS menu bar app for it, called Cybokron Limit Guard. This post is less about the app and more about how it works: where Codex keeps the signals you need, why I avoided keystroke automation, and which guardrails I think every auto-continue tool needs.Screenshot - Sample data Where the signals live. Codex already exposes almost everything you need through two local sources. The first is codex app-serverCodex's own local API. It speaks newline-delimited JSON-RPC, and account/rateLimits/read returns the 5-hour and weekly windows with their used percentage and reset time, plus a field called ordinaryUsageAllowed. It also lists the usage-limit reset credits on the account, each with an id, a status, and an expiry date. The protocol is marked as experimental, so I treat every field defensively.The second is the session log. Each Codex session writes a JSONL "rollout" file under ~/.codex/sessions/. Every turn ends with a task_complete event, and when a turn was cut off by the limit, its error carries usage_limit_exceeded.That single field is the difference between "the agent finished" and "the agent was interrupted". Finished turns, overload errors,s and aborted turns all look different, so the app can tell them apart without guessing.Don't trust the clock, trust the gate. My first idea was simple: read the reset time, set a timer, and send "continue" when it fires. That is not safe, and Codex's own schema says so: clients must not infer recovery from percentages or reset times. So the reset time only schedules the first check. The real gate is ordinaryUsageAllowed == true from a fresh read that is less than 30 seconds old. If the value is false, Limit Guard keeps polling with back-off.If it is null or cannot be decoded, the app does nothing. Polling also adapts: every five minutes normally, every minute once a window passes 90%, and every 30 seconds right after a reset.No keystrokes. The obvious way to "type continue" is to automate Terminal with AppleScript or synthetic key presses. I designed that path and then left it out of the first version. Typing into a terminal you can't fully see is risky: you might press Enter on an option picker or add text to a half-written prompt. Codex already has a cleaner route. The Terminal session talks to a shared app-server daemon, and codex app-server proxy connects to that same daemon. A turn/start call with a thread ID starts a new turn in exactly that conversation, and the turn shows up in the user's Terminal tab. The turn keeps the thread's model, approval, and sandbox settings, because the app never overrides them. As a result, the app needs no Automation or Accessibility permission. If the daemon can't be reached, the app does not fall back to typing; it simply asks you to continue by hand.Each continue carries a fresh clientUserMessageId. Within two minutes, the app looks for thatIDd or a new turn in the thread. If it can't confirm delivery, it marks the attempt as unconfirmed and never resends it on its own. You get a "Send again" button instead.The message is written in the conversation's language. Apple's NaturalLanguage framework reads the last few real user messages, skips injected context such as AGENTS.md, and picks "continue" or "devam et." The table is editable, so you can add other languages.Guardrails for an agent that talks to an agent. Sending messages to an AI agent on someone's behalf can go wrong quietly, so most of the design is about knowing when to say no. Opt-in sessions only. Nothing is guarded by default. You tick Codex sessions to let the app continue. A countdown. A 10-second countdown runs before each continue by default, and you can cancel it. Re-checks before sending. The session must still be waiting, the same Codex process must still be running, and the app must not be paused. A loop guard. The app sends at most three continues in a row per thread, with at least two minutes between them. A runaway brake. If three auto-continued turns in a row each end within a minute, the agent is probably not making progress, so the app stops. A read-only mode. If a field the actions depend on disappears after a Codex update, the app keeps showing usage but pauses every automatic action. A notice on first launch. Nothing automatic happens until you read and accept it. Reset credits, handled carefully. Some accounts receive usage-limit reset credits that expire. The app lists them with their expiry dates and puts the ones expiring within 24 hours first. A manual reset always asks for confirmation. Automatic use is off by default. If you turn it on, the app spends one credit when the weekly limit reaches a threshold, 97% by default. It does this at most once per account every seven days, only while Codex is actually in use, and never when the weekly window would reset on its own within 12 hours. It always picks the credit that expires first.A call that spends something needs idempotency. Before calling the consume endpoint, the app writes a ledger entry with a UUID idempotency key. If the call times out or the app crashes, it retries with the same key, so one intended reset can't turn into two. In the test suite, every spend path runs against a fake app-server, and the real endpoint is never called.Forecast and history. From recent samples, the app estimates how fast you are using each window and shows a line such as "at this pace the weekly limit runs out around Fri 14:00". A chart shows your daily token use for the last 7, 30, or 90 days, together with the history of both windows. Privacy Everything stays on your Mac. The app reads session files only to detect stops and the conversation language. It never copies conversation text into its own files, never reads Codex's credential file,e and has no analytics. It talks only to Codex's local app-server and to GitHub for updates. What the first version covers. Version 0.1.1 supports the Codex CLI running in Terminal.app on macOS 14 Sonoma or later, with one universal build for Apple Silicon and Intel. You need to be signed into ChatGPT. (codex login). The interface is available in English and Turkish. Other terminals and editors, the Codex desktop app, other agents such as Claude Code, and multiple accounts are on the roadmap. The app does not bypass any limit. It waits until Codex reports that usage is allowed again, or it uses a credit you already have. Automated use may still conflict with your platform's terms, so read them before you turn on automatic actions.Try It Limit Guard is written in Swift with AppKit and SwiftUI, has no third-party dependencies, and is notarized by Apple. It is free under the MIT license. You can download it from cybokron.com and read the source code on GitHub. Issues, ideas,s and pull requests are welcome. Screenshots: Disclosure: I developed Cybokron Limit Guard. It is a free, open-source, independent tool and is not affiliated with or endorsed by OpenAI.
How I Made Codex CLI Resume Itself After Hitting a Usage Limit
Full Article
Original Source
Read the full article at Hackernoon →KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.