Skip to content

feat(roles): add claude_cli provider — run kernel via Claude Code CLI#38

Merged
Protocol-zero-0 merged 1 commit into
mainfrom
feat/claude-cli-provider
May 26, 2026
Merged

feat(roles): add claude_cli provider — run kernel via Claude Code CLI#38
Protocol-zero-0 merged 1 commit into
mainfrom
feat/claude-cli-provider

Conversation

@Protocol-zero-0

Copy link
Copy Markdown
Owner

Summary

Adds a third LLM provider alongside anthropic and openai. Set llm.provider: claude_cli in evolution.yml to drive planner / evaluator / goal_evaluator / strategist through the local claude binary instead of an API key.

Why: the bundled examples (oss_fix_demo) already use claude CLI for the executor, but the planning roles still required an Anthropic API key. With this, a Claude Pro subscription is enough to run the full kernel — drops the bar for evaluators / readers who try the README quickstart.

Implementation

  • Each of the four LLM-driven roles gets a _call_claude_cli(prompt, model) that shells out to claude -p --model <model> --output-format json and reads result from the JSON envelope.
  • planner.py and evaluator.py additionally read total_cost_usd and usage.{input,output}_tokens from the JSON so the kernel-level cost guards keep working (no free pass through cost accounting just because there's no API bill).
  • All four roles route through the existing provider switch; default behavior unchanged.
  • No new dependency — uses stdlib subprocess + json.

Compatibility

Opt-in only. Existing configs continue to work bit-for-bit. Targets a v1.2.0 minor release.

Test plan

  • CI green on this PR
  • manual: an evolution.yml with llm.provider: claude_cli runs end-to-end against a target repo using only Claude Pro (no ANTHROPIC_API_KEY)
  • verify total_cost_usd numbers from claude -p flow into runs/NNNN/decision.json cost field
  • (post-merge) cut v1.2.0 tag + GitHub Release + twine upload

Adds a third LLM provider alongside anthropic and openai. Set
`llm.provider: claude_cli` in evolution.yml to drive planner / evaluator
/ goal_evaluator / strategist through the local `claude` binary instead
of an API key.

Why: the bundled examples (oss_fix_demo) already use claude CLI for the
executor, but the planning roles still required an Anthropic API key.
With this, a Claude Pro subscription is enough to run the full kernel —
lowers the bar for evaluators / readers who try the README quickstart.

Implementation:
- Each role gets a `_call_claude_cli(prompt, model)` that shells out to
  `claude -p --model <model> --output-format json`, reads `result` from
  the JSON envelope. Planner / evaluator also read `total_cost_usd` and
  total tokens so the kernel-level cost guards keep working.
- All four roles route through the existing `provider` switch; default
  behavior unchanged (provider defaults stay anthropic / openai).
- No new dependency — uses stdlib subprocess + json.

Defaults: opt-in only. Existing configs continue to work bit-for-bit.

Targets a v1.2.0 minor release.
Copilot AI review requested due to automatic review settings May 26, 2026 08:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new opt-in LLM provider (claude_cli) so the kernel’s planning/evaluation roles can run via the local claude CLI (instead of requiring API keys), while still attempting to propagate token/cost accounting where available.

Changes:

  • Added claude_cli provider branches to planner, evaluator, goal_evaluator, and strategist roles.
  • Implemented Claude CLI subprocess calls using --output-format json, parsing result (and in planner/evaluator, token usage + total_cost_usd).
  • Routed the new provider through the existing llm.provider switch in each role.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
roles/strategist.py Adds claude_cli CLI invocation path for strategy generation.
roles/planner.py Adds claude_cli path returning text + tokens + cost for cost guards.
roles/goal_evaluator.py Adds claude_cli path for goal completion evaluation.
roles/evaluator.py Adds claude_cli handling in _call_llm, including usage/cost parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread roles/strategist.py
Comment on lines +44 to +49
proc = subprocess.run(
["claude", "-p", "--model", model, "--output-format", "json"],
input=prompt,
capture_output=True,
text=True,
)
Comment thread roles/planner.py
Comment on lines +55 to +60
proc = subprocess.run(
["claude", "-p", "--model", model, "--output-format", "json"],
input=prompt,
capture_output=True,
text=True,
)
Comment thread roles/goal_evaluator.py
Comment on lines +44 to +49
proc = subprocess.run(
["claude", "-p", "--model", model, "--output-format", "json"],
input=prompt,
capture_output=True,
text=True,
)
Comment thread roles/evaluator.py
Comment on lines +46 to +51
proc = subprocess.run(
["claude", "-p", "--model", model, "--output-format", "json"],
input=prompt,
capture_output=True,
text=True,
)
@Protocol-zero-0 Protocol-zero-0 merged commit fd0d34a into main May 26, 2026
8 checks passed
@Protocol-zero-0 Protocol-zero-0 deleted the feat/claude-cli-provider branch May 26, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants