codex-self-iter is a plugin-style repository that runs a continuous autonomous goal loop:
- Read
TASK.md+plan.md - Execute one autonomous iteration in the repository
- Require the agent to emit a concrete
next_goal - Persist that goal and continue from it
- Repeat until completion/stop condition
.
├── .codex-plugin/plugin.json
├── src/codex_self_iter/
├── tests/
├── examples/
├── scripts/
├── pyproject.toml
└── .github/workflows/ci.yml
- Install locally:
pip install -e .[dev]- Prepare task files in your workspace:
TASK.md(optional)plan.md(required)
- Run:
python3 -m codex_self_iter \
--workspace . \
--task-file TASK.md \
--plan-file plan.md \
--state-dir .codex-self-iter \
--agent-command-template "scripts/invoke-codex-agent.sh {prompt_file} {workspace}"Or use:
./scripts/run-local.sh .- Create
.codex-self-iter/STOP - Or create workspace-level
.codex-stop - Or interrupt process manually
.codex-self-iter/prompts/: planner/executor/reviewer prompts.codex-self-iter/logs/iterations.jsonl: loop records.codex-self-iter/status.json: last iteration state.codex-self-iter/runtime.json: persisted backoff counters and window.codex-self-iter/loop.lock: single-instance guard file
See config.example.toml.
Important fields:
agent_command_templatemust include{prompt_file}max_iterations = 0means unbounded loopmax_stagnationprevents infinite cycling on identicalnext_focusno_change_gatethrottles no-op loops when no new git changes appearbackoff_*fields control exponential cooldown behaviorlock_file_namecontrols the single-instance lock path under state-dircompletion_promisemarks completion when included in output
Default wrapper scripts/invoke-codex-agent.sh uses:
codex -a never exec ...
This means the run does not ask for manual approval prompts.
Optional bypass mode:
export CODEX_SELF_ITER_AGENT_MODE=bypassIn bypass mode, wrapper uses:
codex --dangerously-bypass-approvals-and-sandbox exec ...
This disables approvals and sandboxing entirely. Use only in externally sandboxed environments.
When running under launchd (or other service managers), interactive shell PATH is often not inherited.
If codex is not found, set an explicit binary path:
export CODEX_BIN=/absolute/path/to/codexThe default wrapper checks in this order:
CODEX_BIN(if executable)PATHviacommand -v codex- common fallback paths (nvm/Homebrew/local bin)
Run tests:
pytest -qThe loop is autonomous at application logic level but still bounded by host permissions, sandbox policy, and tool confirmations.