feat(harness): agent_loop foundation — non-interactive CLI driver (#30 PR1)#31
Open
k-buchi4696 wants to merge 1 commit into
Open
feat(harness): agent_loop foundation — non-interactive CLI driver (#30 PR1)#31k-buchi4696 wants to merge 1 commit into
k-buchi4696 wants to merge 1 commit into
Conversation
…PR1) issue #30 の foundation レイヤを実装。autoforge が agent CLI (Claude Code / Codex CLI) を 非対話 subprocess で叩いて結果を構造化して受け取るための最小モジュールを新設する。 本 PR ではライブラリ層のみで CLI 統合は行わない(PR2 以降)。 新規 autoforge/harness/agent_loop.py: - `Backend` (str enum): "claude" / "codex" - `AgentResult` (frozen dataclass): backend, success, exit_code, stdout, stderr, duration_seconds - `_argv_claude(prompt)` → ["claude", "-p", prompt] - `_argv_codex(prompt)` → ["codex", "exec", prompt] - `build_argv(backend, prompt)` — public dispatcher - `run_agent(backend, prompt, *, cwd=None, timeout=600)` — subprocess.run の wrapper。TimeoutExpired / FileNotFoundError を AgentResult に正規化(呼び出し 側で try/except 不要) 新規 tests/harness/test_agent_loop.py: - argv snapshot 4 件 (`_argv_claude` / `_argv_codex` / `build_argv` の 2 dispatch) - `run_agent` mock subprocess 5 件: - 成功 (exit 0 → success=True, stdout 伝搬) - 非ゼロ終了 (success=False) - タイムアウト (exit_code=-1, stderr に "Timeout after Ns") - CLI 不在 (exit_code=-2, stderr に "not found on PATH") - cwd 引数の subprocess.run への透過 スコープ外(後続 PR): - PATH 自動検出 → PR2 - \`autoforge loop --mode goals --backend ...\` → PR2 - goals dispatch from autoforge.yml → PR3 - ドキュメント → PR4 557 tests pass (既存 548 + 新規 9). Refs #30 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
issue #30 を 4 PR で実装する内、PR1 (foundation) に相当。
autoforge が agent CLI (Claude Code / Codex CLI) を非対話 subprocess で叩いて結果を構造化して受け取るための最小モジュールを新設する。ライブラリ層のみで、CLI フラグ統合や goals 実行フローは含まない(PR2 以降)。
変更内容
新規 `autoforge/harness/agent_loop.py` (~140 行)
新規 `tests/harness/test_agent_loop.py` (~115 行)
Test Plan
スコープ外(後続 PR)
Refs
loop --mode goals --backend {auto,claude,codex}を新規実装 #30🤖 Generated with Claude Code