Skip to content

Commit 6784447

Browse files
authored
Merge pull request #8 from weijt606/v0.2.3
fix: refresh CLI agent adapters for upstream changes — Codex, OpenCode, Claude Code (v0.2.3)
2 parents e0f5c22 + 678b9ca commit 6784447

13 files changed

Lines changed: 87 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [0.2.3] - 2026-05-26
8+
9+
### Fixed
10+
- **Codex adapter** — switched to `codex exec` headless mode; the old
11+
`codex --quiet --auto-edit` invocation was removed upstream. Also adds
12+
`--skip-git-repo-check` (the optimization workspace isn't a git repo) and
13+
`--sandbox workspace-write` (lets the agent edit within the workspace).
14+
- **OpenCode adapter** — switched to the `opencode run` subcommand; the
15+
top-level `-p` flag is no longer supported upstream.
16+
- **Claude Code adapter** — add `--permission-mode acceptEdits` so the agent can
17+
actually write candidate files in headless `-p` mode (recent Claude Code blocks
18+
edits without it); drop `--verbose` (noise in print mode).
19+
20+
### Changed
21+
- **Claude Code adapter** now pins `--model claude-opus-4-7` (Opus 4.7,
22+
highest-capability) for the Proposer.
23+
- Default proposer model `claude-sonnet-4-20250514``claude-sonnet-4-6`
24+
(affects `api`/`openai` backends; other CLI backends use their own model).
25+
- Verified `claude-code` (`claude -p`) and `hermes` (`hermes chat -q`) are still
26+
current; `claw-code` mirrors Claude Code (unverified, low usage).
27+
- Docs (README / README_CN / technical-architecture) updated to the current CLI
28+
invocations.
29+
730
## [0.2.2] - 2026-05-24
831

932
### Added

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ Just add `ph wrap --auto-evolve` in front of your agent command (pick the one ma
303303
# CLI agent backends — wrap the agent you already use
304304
ph wrap --auto-evolve claude -p "Refactor the auth module to use JWT" # Claude Code
305305
ph wrap --auto-evolve claw -p "Write integration tests for payments" # Claw Code
306-
ph wrap --auto-evolve codex "Add retry logic to the API client" # Codex
306+
ph wrap --auto-evolve codex exec "Add retry logic to the API client" # Codex
307307
ph wrap --auto-evolve hermes chat -q "Refactor the DB connection pool" # Hermes Agent
308-
ph wrap --auto-evolve opencode -p "Fix the flaky parser test" # OpenCode
308+
ph wrap --auto-evolve opencode run "Fix the flaky parser test" # OpenCode
309309

310310
# Local models — wrap the CLI command directly
311311
ph wrap --auto-evolve ollama run gemma3 "Summarize this document" # Ollama
@@ -373,9 +373,9 @@ After that, just use your agent as usual:
373373
```bash
374374
claude -p "Refactor auth to JWT" # automatically becomes: ph wrap --auto-evolve claude -p ...
375375
claw -p "Write payment tests" # same — auto-wrapped
376-
codex "Add retry logic" # same
376+
codex exec "Add retry logic" # same
377377
hermes chat -q "Refactor pool" # same
378-
opencode -p "Fix flaky test" # same
378+
opencode run "Fix flaky test" # same
379379
```
380380

381381
How it works: a `preexec` hook in your shell detects `claude`/`claw`/`codex`/`hermes`/`opencode` commands and transparently redirects them through `ph wrap --auto-evolve`. Your output is unchanged.
@@ -466,9 +466,9 @@ The Proposer reads **all of this** before generating the next candidate. It can
466466
| `openai` || OpenAI-compatible API (Ollama, vLLM, LM Studio, etc). Needs `OPENAI_API_KEY` |
467467
| `claude-code` | `claude -p` | Official Claude Code CLI (Pro/Teams subscription) |
468468
| `claw-code` | `claw -p` | Open-source Claw Code CLI |
469-
| `codex` | `codex --quiet` | OpenAI Codex CLI |
469+
| `codex` | `codex exec` | OpenAI Codex CLI |
470470
| `hermes` | `hermes chat -q` | Nous Research [Hermes Agent](https://github.com/NousResearch/hermes-agent) CLI |
471-
| `opencode` | `opencode -p` | OpenCode CLI |
471+
| `opencode` | `opencode run` | OpenCode CLI |
472472
| `local` || Offline rule-based engine for development & testing |
473473

474474
`ph doctor` auto-detects all available backends and shows their status.
@@ -543,7 +543,7 @@ proposer:
543543
backend: api # api | openai | claude-code | claw-code | codex | hermes | opencode | local
544544
ensemble: [] # If non-empty, pick among these backends per iteration via a UCB bandit
545545
bandit_c: 1.41421356 # UCB exploration constant (higher = more exploration)
546-
model: claude-sonnet-4-20250514 # Model name (for api/openai backends)
546+
model: claude-sonnet-4-6 # Model name (for api/openai backends)
547547
base_url: null # Custom API endpoint (for openai backend)
548548
api_key: null # API key override (null = use env var)
549549
max_tokens: 16384 # Max output tokens per proposer turn
@@ -772,9 +772,9 @@ polyharness/
772772
│ │ └── adapters/ # Per-agent CLI adapters
773773
│ │ ├── claude_code.py # claude -p
774774
│ │ ├── claw_code.py # claw -p
775-
│ │ ├── codex.py # codex --quiet --auto-edit
775+
│ │ ├── codex.py # codex exec
776776
│ │ ├── hermes.py # hermes chat -q
777-
│ │ └── opencode.py # opencode -p
777+
│ │ └── opencode.py # opencode run
778778
│ └── templates/ # 5 built-in task templates
779779
│ ├── text-classification/
780780
│ ├── math-word-problems/

README_CN.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ ph clean --keep-best # 清理候选目录释放磁盘空间
303303
# CLI agent 后端 —— 直接包裹你已经在用的 agent
304304
ph wrap --auto-evolve claude -p "把 auth 模块重构为 JWT 方案" # Claude Code
305305
ph wrap --auto-evolve claw -p "给支付服务写集成测试" # Claw Code
306-
ph wrap --auto-evolve codex "给 API 客户端加上重试逻辑" # Codex
306+
ph wrap --auto-evolve codex exec "给 API 客户端加上重试逻辑" # Codex
307307
ph wrap --auto-evolve hermes chat -q "重构数据库连接池" # Hermes Agent
308-
ph wrap --auto-evolve opencode -p "修复不稳定的 parser 测试" # OpenCode
308+
ph wrap --auto-evolve opencode run "修复不稳定的 parser 测试" # OpenCode
309309

310310
# 本地模型 —— 直接包裹 CLI 命令
311311
ph wrap --auto-evolve ollama run gemma3 "总结这篇文档" # Ollama
@@ -373,9 +373,9 @@ ph shell-hook install # 一次性设置,写入 ~/.zshrc
373373
```bash
374374
claude -p "把 auth 重构为 JWT" # 自动变为:ph wrap --auto-evolve claude -p ...
375375
claw -p "写支付测试" # 同理——自动包裹
376-
codex "加重试逻辑" # 同理
376+
codex exec "加重试逻辑" # 同理
377377
hermes chat -q "重构连接池" # 同理
378-
opencode -p "修复不稳定测试" # 同理
378+
opencode run "修复不稳定测试" # 同理
379379
```
380380

381381
原理:shell 的 `preexec` 钩子检测到 `claude`/`claw`/`codex`/`hermes`/`opencode` 命令后,透明地通过 `ph wrap --auto-evolve` 转发。你的输出不会变。
@@ -466,9 +466,9 @@ Proposer 在生成下一个候选之前会读取**所有这些信息**。它能
466466
| `openai` || 兼容 OpenAI 格式的本地/云端模型直连 (Ollama, vLLM, LM Studio 等),需配置 `OPENAI_API_KEY` |
467467
| `claude-code` | `claude -p` | 官方 Claude Code CLI(Pro/Teams 订阅) |
468468
| `claw-code` | `claw -p` | 开源 Claw Code CLI |
469-
| `codex` | `codex --quiet` | OpenAI Codex CLI |
469+
| `codex` | `codex exec` | OpenAI Codex CLI |
470470
| `hermes` | `hermes chat -q` | Nous Research [Hermes Agent](https://github.com/NousResearch/hermes-agent) CLI |
471-
| `opencode` | `opencode -p` | OpenCode CLI |
471+
| `opencode` | `opencode run` | OpenCode CLI |
472472
| `local` || 离线规则引擎,用于开发和测试 |
473473

474474
`ph doctor` 会自动检测所有可用后端并显示状态。
@@ -543,7 +543,7 @@ proposer:
543543
backend: api # api | openai | claude-code | claw-code | codex | hermes | opencode | local
544544
ensemble: [] # 非空时,每轮用 UCB bandit 在这些后端中择优
545545
bandit_c: 1.41421356 # UCB 探索常数(越大越偏探索)
546-
model: claude-sonnet-4-20250514 # 模型名称(api/openai 后端使用)
546+
model: claude-sonnet-4-6 # 模型名称(api/openai 后端使用)
547547
base_url: null # 自定义 API 端点(openai 后端使用)
548548
api_key: null # API 密钥覆盖(null = 使用环境变量)
549549
max_tokens: 16384 # 每轮 proposer 最大输出 token 数
@@ -772,9 +772,9 @@ polyharness/
772772
│ │ └── adapters/ # 逐 agent CLI 适配器
773773
│ │ ├── claude_code.py # claude -p
774774
│ │ ├── claw_code.py # claw -p
775-
│ │ ├── codex.py # codex --quiet --auto-edit
775+
│ │ ├── codex.py # codex exec
776776
│ │ ├── hermes.py # hermes chat -q
777-
│ │ └── opencode.py # opencode -p
777+
│ │ └── opencode.py # opencode run
778778
│ └── templates/ # 5 个内置任务模板
779779
│ ├── text-classification/
780780
│ ├── math-word-problems/

docs/development/technical-architecture.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ search:
159159

160160
# Proposer 配置
161161
proposer:
162-
model: "claude-sonnet-4-20250514" # Proposer 模型
162+
model: "claude-sonnet-4-6" # Proposer 模型
163163
max_tokens: 16384 # 单次输出上限
164164
temperature: 0.7 # 生成温度
165165
backend: "api" # api | claude-code | claw-code
@@ -222,7 +222,7 @@ harness:
222222
{
223223
"iteration": 3,
224224
"parent": "iter_1",
225-
"proposer_model": "claude-sonnet-4-20250514",
225+
"proposer_model": "claude-sonnet-4-6",
226226
"proposer_reasoning": "iter_1 在 task_002 上失败因为缺少 retry 逻辑...",
227227
"changes_summary": "添加了 exponential backoff retry 到 API 调用层",
228228
"timestamp": "2026-04-02T14:30:00Z"
@@ -1254,7 +1254,7 @@ ablation:
12541254
```yaml
12551255
proposer:
12561256
model: "claude-haiku-4-20250414" # 低成本模式
1257-
# model: "claude-sonnet-4-20250514" # 平衡模式
1257+
# model: "claude-sonnet-4-6" # 平衡模式
12581258
# model: "claude-opus-4-20250514" # 最强模式(论文设置)
12591259
```
12601260

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polyharness",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Make your AI agent evolve automatically through iterative harness optimization.",
55
"keywords": [
66
"agent",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "polyharness"
7-
version = "0.2.2"
7+
version = "0.2.3"
88
description = "Automated harness optimization for AI agents — make your agent evolve."
99
readme = "README.md"
1010
license = "MIT"

src/polyharness/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""PolyHarness — Automated harness optimization for AI agents."""
22

3-
__version__ = "0.2.2"
3+
__version__ = "0.2.3"

src/polyharness/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class ProposerConfig(BaseModel):
8484
description="UCB exploration constant for ensemble selection. Higher = more exploration.",
8585
)
8686
model: str = Field(
87-
default="claude-sonnet-4-20250514", description="Model for the Proposer agent."
87+
default="claude-sonnet-4-6",
88+
description="Model for the Proposer agent (api/openai backends; CLI backends use their own).",
8889
)
8990
base_url: str | None = Field(
9091
default=None, description="Optional base URL for the API (useful for local models)."

src/polyharness/proposer/adapters/claude_code.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
33
Invokes the official `claude` CLI in print mode (-p).
44
Requires an active Claude Code subscription.
5+
6+
Verified against Claude Code (May 2026):
7+
- `-p` headless mode and `--output-format text` are current.
8+
- `--permission-mode acceptEdits` is REQUIRED for the agent to write files
9+
non-interactively (auto-approves Read/Edit/Write); without it, headless edits
10+
are blocked. `acceptEdits` still gates arbitrary Bash/network (least-privilege,
11+
appropriate for the isolated workspace).
12+
- `--model claude-opus-4-7` pins to Opus 4.7 (full name for reproducibility).
513
"""
614

715
from __future__ import annotations
816

917
from polyharness.proposer.adapters.base import CLIAdapter
1018

19+
# Pinned Proposer model for the Claude Code backend (highest-capability).
20+
CLAUDE_CODE_MODEL = "claude-opus-4-7"
21+
1122

1223
class ClaudeCodeAdapter(CLIAdapter):
1324
"""Adapter for the Claude Code CLI (`claude`)."""
@@ -24,8 +35,9 @@ def build_command(self, prompt: str, *, cli_path: str | None = None) -> list[str
2435
binary = cli_path or self.default_binary
2536
return [
2637
binary,
27-
"-p", # print mode (non-interactive, stdout output)
38+
"-p", # print mode (non-interactive)
2839
prompt,
40+
"--model", CLAUDE_CODE_MODEL, # pin to Opus 4.7
41+
"--permission-mode", "acceptEdits", # auto-approve file edits (headless)
2942
"--output-format", "text",
30-
"--verbose",
3143
]

src/polyharness/proposer/adapters/codex.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Codex CLI adapter.
22
3-
Invokes OpenAI's `codex` CLI agent in quiet/non-interactive mode.
3+
Invokes OpenAI's `codex` CLI agent in headless/non-interactive mode via
4+
`codex exec` (the old `--quiet`/`--auto-edit` flags were removed upstream).
5+
See: developers.openai.com/codex/noninteractive
46
"""
57

68
from __future__ import annotations
@@ -23,7 +25,8 @@ def build_command(self, prompt: str, *, cli_path: str | None = None) -> list[str
2325
binary = cli_path or self.default_binary
2426
return [
2527
binary,
26-
"--quiet",
27-
"--auto-edit", # allow file edits without confirmation
28+
"exec", # headless, non-interactive mode
29+
"--skip-git-repo-check", # the workspace is not a git repo
30+
"--sandbox", "workspace-write", # allow edits within the workspace cwd
2831
prompt,
2932
]

0 commit comments

Comments
 (0)