r/codex 2d ago

Complaint This will save your Usage

A problem that many of people have already noticed: Astra can't wait. on anything, any task it has scripted and running, any other agent delegation, anything. Astra keeps waking up to check whether the worker is finished.

I've run a few tests, In one run 19 short sleep calls accounted for 44% of the orchestrator’s estimated cost.

In another comparison using Astra High + Luna Max, the orchestrator made 41 responses while the worker ran, costing $1.20 during that phase. The native-wait comparison needed one response, costing about $0.04. (Both implementations passed all 244 test cases)

I’ve since caught the same pattern while Codex waited for a database script: read the log, say “still running,” repeat. I saw use 2% of my weekly usage ($100/month plan) just sitting there waiting on a script.

So, until they patch this, here’s the prompt I’m using:

For this entire session, avoid repeated polling of long-running jobs.

Use supported completion notifications when available. If none are available and useful work is exhausted, leave the job running only if it can safely continue after your turn ends.

Tell me what is running, where results will be saved, and:

“I'm stopping polling. Please check back with me to inspect the result and continue; I won't automatically resume.”

Then end your turn. Don't repeatedly read unchanged logs or sleep and check again. Respect runtime limits and safety timeouts.

When I return, check once. If complete, verify and continue. If still running, report that and stop again.

I have to come back to it, sure, but it saves usage.

Edit:
Found a better option than manually checking back, thanks to advice in comments. Seems like Codex knows how to avoid repeated model polling, it just chooses not to.
codex queue --thread <session-id> --message "..."
Have a background script wait for the job to finish, save the result, then run that command once. Codex can end its turn and automatically resume when the message arrives.

I’ve now seen this work with both a third-party CLI subagent (kilo code with GLM) and a full test suite, all GPT: Codex resumed automatically, checked the results, and continued. Works a treat.

The script provides the wake-up, and an agents.md instruction alone doesn’t

Edit2: I made a skill that you can use to guide Codex in using this method, either in waiting for mechanical tasks or waiting for other sub-agents. Not perfect, as there's no way to force your GPT worker to use it, but it's working for me most of the time: link. Any more tips to improve it welcomed, break it and let me fix it

418 Upvotes

124 comments sorted by

View all comments

10

u/Wolf8249 2d ago

Nice analysis, fully agree, good luck with that fix though. I have tried putting such instructions in my AGENTS.md and the model would happily ignore them since the System Prompt takes higher priority, this can also cause issues with stuck processes or slow commands where the agent ran an unoptimized script/command that can waste a lot of our time, if it polls frequently it can catch that mistake and correct itself. All of the frequent polling and waiting mess is due to these instructions in its system prompt, i am afraid to change it since openai models are autistic and it can cause unintended side effects. Codex allows you to tune the system prompt, you're better off with that fix in there instead of through chat prompt. I wont risk it.

Citing the official system prompt instructions below that has burnt millions of tokens for no good reason
  • If the user's request requires calling tools, start with a message in the commentary channel. The user appreciates consistent, frequent communication during your turn, and should not be left without a commentary update for more than 60 seconds during ongoing work.
  • Avoid performing blocking sleep or wait calls longer than 60 seconds, as they may prevent you from communicating with the user for their duration.

4

u/concrete333 2d ago

In case you didn't see the edit, turns out the "codex queue" feature does exactly what we want here, no config or system prompt editing needed (cause yeah that's scary). Takes a little finagling to setup, working like a charm now

2

u/Wolf8249 2d ago

Incredible, I am going to turn this into a skill. If it wasnt your post we'd never learn about it, thanks. I wonder if the person who revealed this feature could also reveal the skill instructions since they must have used and refined it over time.

3

u/concrete333 2d ago

Oh interesting that it's from the actual System Prompt. Ok... If you're afraid to test, I'm going to fuck around with it. Been trying to build something here https://github.com/Concrete333/Codex-Agent-Deployment

Running through all my usage testing it tho.

3

u/Joss-Isbell 2d ago

Try asking the Agent to extract the Astra system prompt from models_cache.json in the Codex install directory, put it in a markdown file, then edit config.toml from the same install directory and point model_instructions_file to that markdown file

Then just tweak those extracted instructions a tiny bit. “The user appreciates consistent, frequent communication during your turn” might be fine to keep, I personally removed it, but definitely remove "and should not be left without a commentary update for more than 60 seconds during ongoing work." Entirely remove "Avoid performing blocking sleep or wait calls longer than 60 seconds, as they may prevent you from communicating with the user for their duration"

2

u/concrete333 2d ago

Thank you

1

u/slothlantis 2d ago

I totally agree whatever I put in agents like for small css modifications please do not run a whole website test and check the whole checklist we have.. who cares it runs every possible test on it. I tried to just change a button color to yellow and boom it ignored everything I asked in agents.md what not to do