Skip to content

Commit d4cc594

Browse files
committed
Fix Codex invocation and add auto-approval wrapper modes
1 parent 04bc6a1 commit d4cc594

6 files changed

Lines changed: 49 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Fixed default agent invocation to use valid Codex CLI arguments.
6+
- Added `scripts/invoke-codex-agent.sh` wrapper.
7+
- Added support for two execution modes:
8+
- `-a never` default (no manual approvals)
9+
- `--dangerously-bypass-approvals-and-sandbox` via `CODEX_SELF_ITER_AGENT_MODE=bypass`
10+
311
## 0.1.0 - 2026-04-21
412

513
- Initial public repository structure for `codex-self-iter`.

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ python3 -m codex_self_iter \
4242
--task-file TASK.md \
4343
--plan-file plan.md \
4444
--state-dir .codex-self-iter \
45-
--agent-command-template "codex exec --auto --prompt-file {prompt_file}"
45+
--agent-command-template "scripts/invoke-codex-agent.sh {prompt_file} {workspace}"
4646
```
4747

4848
Or use:
@@ -73,6 +73,24 @@ Important fields:
7373
- `max_iterations = 0` means unbounded loop
7474
- `max_stagnation` prevents infinite cycling on identical `next_focus`
7575

76+
## Approval and Privilege Mode
77+
78+
Default wrapper `scripts/invoke-codex-agent.sh` uses:
79+
80+
- `codex -a never exec ...`
81+
This means the run does not ask for manual approval prompts.
82+
83+
Optional bypass mode:
84+
85+
```bash
86+
export CODEX_SELF_ITER_AGENT_MODE=bypass
87+
```
88+
89+
In bypass mode, wrapper uses:
90+
91+
- `codex --dangerously-bypass-approvals-and-sandbox exec ...`
92+
This disables approvals and sandboxing entirely. Use only in externally sandboxed environments.
93+
7694
## Development
7795

7896
Run tests:

config.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Required:
22
# Must include {prompt_file}; may include {workspace}.
3-
agent_command_template = "codex exec --auto --prompt-file {prompt_file}"
3+
agent_command_template = "scripts/invoke-codex-agent.sh {prompt_file} {workspace}"
44

55
# 0 means unbounded loop until stop condition.
66
max_iterations = 0

scripts/invoke-codex-agent.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $# -lt 2 ]]; then
5+
echo "usage: $0 <prompt-file> <workspace>" >&2
6+
exit 2
7+
fi
8+
9+
prompt_file="$1"
10+
workspace="$2"
11+
12+
# Default mode: auto-confirm approval requests while keeping sandboxing.
13+
if [[ "${CODEX_SELF_ITER_AGENT_MODE:-}" == "bypass" ]]; then
14+
# Extremely dangerous: no approval prompts and no sandbox.
15+
cat "$prompt_file" | codex --dangerously-bypass-approvals-and-sandbox exec -C "$workspace" -
16+
else
17+
# No manual confirmation; command failures are returned directly to the model.
18+
cat "$prompt_file" | codex -a never exec -C "$workspace" -
19+
fi

src/codex_self_iter/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def main() -> int:
1515
parser.add_argument("--state-dir", default=".codex-self-iter", help="State/log directory")
1616
parser.add_argument(
1717
"--agent-command-template",
18-
default="codex exec --auto --prompt-file {prompt_file}",
18+
default="scripts/invoke-codex-agent.sh {prompt_file} {workspace}",
1919
help="Command template; supports {prompt_file} and {workspace}",
2020
)
2121
parser.add_argument("--config", default="", help="TOML config path (optional)")

src/codex_self_iter/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def run(
9898
task_file_name: str = "TASK.md",
9999
plan_file_name: str = "plan.md",
100100
state_dir_name: str = ".codex-self-iter",
101-
agent_command_template: str = "codex exec --auto --prompt-file {prompt_file}",
101+
agent_command_template: str = "scripts/invoke-codex-agent.sh {prompt_file} {workspace}",
102102
config_path: Path | None = None,
103103
) -> int:
104104
task_file = workspace / task_file_name

0 commit comments

Comments
 (0)