feat(roles): add claude_cli provider — run kernel via Claude Code CLI#38
Merged
Conversation
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.
There was a problem hiding this comment.
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_cliprovider branches to planner, evaluator, goal_evaluator, and strategist roles. - Implemented Claude CLI subprocess calls using
--output-format json, parsingresult(and in planner/evaluator, token usage +total_cost_usd). - Routed the new provider through the existing
llm.providerswitch 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 on lines
+44
to
+49
| proc = subprocess.run( | ||
| ["claude", "-p", "--model", model, "--output-format", "json"], | ||
| input=prompt, | ||
| capture_output=True, | ||
| text=True, | ||
| ) |
Comment on lines
+55
to
+60
| proc = subprocess.run( | ||
| ["claude", "-p", "--model", model, "--output-format", "json"], | ||
| input=prompt, | ||
| capture_output=True, | ||
| text=True, | ||
| ) |
Comment on lines
+44
to
+49
| proc = subprocess.run( | ||
| ["claude", "-p", "--model", model, "--output-format", "json"], | ||
| input=prompt, | ||
| capture_output=True, | ||
| text=True, | ||
| ) |
Comment on lines
+46
to
+51
| proc = subprocess.run( | ||
| ["claude", "-p", "--model", model, "--output-format", "json"], | ||
| input=prompt, | ||
| capture_output=True, | ||
| text=True, | ||
| ) |
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
Adds a third LLM provider alongside
anthropicandopenai. Setllm.provider: claude_cliinevolution.ymlto drive planner / evaluator / goal_evaluator / strategist through the localclaudebinary 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
_call_claude_cli(prompt, model)that shells out toclaude -p --model <model> --output-format jsonand readsresultfrom the JSON envelope.planner.pyandevaluator.pyadditionally readtotal_cost_usdandusage.{input,output}_tokensfrom the JSON so the kernel-level cost guards keep working (no free pass through cost accounting just because there's no API bill).providerswitch; default behavior unchanged.subprocess+json.Compatibility
Opt-in only. Existing configs continue to work bit-for-bit. Targets a v1.2.0 minor release.
Test plan
llm.provider: claude_cliruns end-to-end against a target repo using only Claude Pro (noANTHROPIC_API_KEY)total_cost_usdnumbers fromclaude -pflow intoruns/NNNN/decision.jsoncost fieldtwine upload