guardrail by neatproxy join discord
tool: Codex env: Elixir Phoenix App

How to Stop Codex Loops in Elixir Phoenix App: Fix 'Recursive analysis of every Dockerfile layer on rebuild'

avg. estimated token loss per run: $$4–$50 per incident (depending on Docker image size, project complexity, and retry depth) usd

what is happening

Codex can become trapped repeatedly inspecting every Docker build layer and rerunning Mix compilation when non-critical warnings or cached build inconsistencies prevent a successful rebuild. Instead of isolating the root cause, the agent reanalyzes unchanged Dockerfile layers and recompiles the application, consuming tokens without making meaningful progress. Narrowing the build scope, leveraging Docker layer caching correctly, and limiting automatic retries prevents recursive build-analysis loops.

manual fix

Build only the affected stage, review the first Mix compilation error or warning that blocks progress, and verify Docker cache behavior before triggering another full rebuild. If Codex repeatedly analyzes identical Dockerfile layers and reruns the same `docker build` or `mix compile` commands without producing a different outcome, stop the session, reset context, and restart with a narrowly scoped debugging task.

check configuration: {{local_config_file}}

capping calls & killing loops automatically

if you want to prevent runaway background processes from burning through API credits, you can set budget caps and loop limits directly in terminal using guardrail.

npx @neatproxy/guardrail --preset codex --target phoenix --max-budget 8.00 --loop-cap 3

running into a different edge case? join us at neat to share logs or ask the team.

→ join the neat discord community