ductor
ductor copied to clipboard
fix(codex): pass prompts via stdin
Summary
Pass Codex prompts through stdin instead of argv on all platforms.
Why
Ductor composes prompts with hooks, background task context, and memory. Passing the full prompt as a command-line argument can exceed Linux argv limits before the Codex CLI starts, raising OSError: [Errno 7] Argument list too long.
Changes
- Use
-as the Codex prompt marker for new and resumedcodex execcalls. - Add optional stdin payload support to the shared CLI subprocess executor.
- Keep Dockerized Codex stdin open with
docker exec -iso piped prompts arrive. - Cover non-streaming, resume, streaming, and CLI parameter command shape with tests.
Validation
uv run pytest tests/cli/test_codex_provider.py tests/integration/test_cli_parameter_flow.py tests/cli/test_executor_timeout.py tests/cli/test_claude_provider.py tests/cli/test_docker_wrap.py -quv run ruff check ductor_bot/cli/base.py ductor_bot/cli/executor.py ductor_bot/cli/codex_provider.py tests/cli/test_codex_provider.py tests/integration/test_cli_parameter_flow.pyuv run mypy ductor_bot
Thanks — this is the right direction: the argv-limit problem is real for ductor's composed prompts, and moving to stdin also keeps the prompt out of /proc/<pid>/cmdline and logs, so it's a net security win too. Before un-drafting:
- Rebase needed: #147 just merged and touches
tests/cli/test_codex_provider.py(same_make_process_mockhelpers) andclaude_provider.py, so this branch will conflict. - Dead parameter: after this change nothing sets
windows_only=Trueon_feed_stdin_and_close(cli/base.py) — please remove it. - Streaming deadlock risk: in the streaming path the whole prompt is written + drained before the stdout read loop starts. For prompts larger than the OS pipe buffer (~64 KiB — exactly the use case this PR targets), if codex starts emitting stdout before consuming stdin,
drain()and the child can deadlock. The oneshot path is safe (communicate), the streaming path isn't — feeding stdin concurrently (asyncio.create_task) or at least documenting the assumption would close this. - Consistency note:
claude_provider.pystill passes the prompt via argv on POSIX and has the same latentArgument list too longbug. Fine to defer, but please state in the PR whether claude moves tostdin_texthere or in a follow-up.
Looking forward to merging this once rebased. 👍