Skip to content

tools: bfoptimizer: support multiple providers through OpenRouter - #623

Merged
qdeslandes merged 1 commit into
meta:mainfrom
qdeslandes:bfoptimizer-openrouter
Oct 29, 2026
Merged

qdeslandes merged 1 commit into
meta:mainfrom
qdeslandes:bfoptimizer-openrouter

Conversation

@qdeslandes

Copy link
Copy Markdown
Contributor

Summary

Replace the Claude Agent SDK and Anthropic SDK integrations with OpenRouter's Chat Completions API. Each phase (proposal, implementation, and commit message) can then use any model available on OpenRouter, instead of a fixed list of Claude models.

  • --proposal-model and --impl-model take OpenRouter model IDs, and the new --commit-model selects the commit message model. bfoptimizer checks the IDs against OpenRouter's model list at startup, and needs OPENROUTER_API_KEY instead of Anthropic credentials.
  • The tool loop that the Claude Agent SDK provided now runs in bfoptimizer, with the same file and shell tools and the same 100-response limit. Reasoning details are passed back between rounds.
  • Transient API failures are retried, and Anthropic models still cache the conversation across tool rounds.
  • Commit message requests now count toward the displayed cost.
  • The anthropic and claude_agent_sdk packages are no longer needed: the transport only uses the Python standard library.

Related issue

None. bfoptimizer was limited to Claude models, and this change removes that limit.

Testing

  • Ran a round of optimizations.
  • Checked retries and timeouts against a local HTTP server, and the startup model check against the live OpenRouter model list.

AI disclosure

Deferred most of the work to Claude, reviewed and owned by me

Checklist

  • I understand every line in this PR and can explain why it is correct
  • I built the project and ran the tests covering this change
  • make -C $BUILD test_bin test passes and the code follows the style guide
  • Commits are formatted as component: subcomponent: short description
  • I have disclosed any AI usage above

@meta-cla meta-cla Bot added the cla signed label Oct 29, 2026
@qdeslandes
qdeslandes marked this pull request as ready for review October 29, 2026 11:35
@qdeslandes
qdeslandes enabled auto-merge (rebase) October 29, 2026 11:35
Replace the Claude SDK integrations with OpenRouter so each optimization
phase and commit generation can use a configured model ID.

Run file and shell tools in a bounded agent loop, preserve reasoning
state between requests, and include commit generation in attempt costs.
Document the setup and the differences from the previous SDK.
@qdeslandes
qdeslandes force-pushed the bfoptimizer-openrouter branch from 4a27d9a to 1c23bd0 Compare October 29, 2026 12:33
@qdeslandes
qdeslandes merged commit f5eb7af into meta:main Oct 29, 2026
38 checks passed
@qdeslandes
qdeslandes deleted the bfoptimizer-openrouter branch October 29, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant