Skip to content

feat: add first-class OpenRouter provider support - #1975

Merged
wpfleger96 merged 1 commit into
mainfrom
duncan/openrouter-provider
Jul 29, 2026
Merged

feat: add first-class OpenRouter provider support#1975
wpfleger96 merged 1 commit into
mainfrom
duncan/openrouter-provider

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

First-class Provider::OpenRouter support joining the existing anthropic/openai/databricks providers. Reuses the Chat Completions path with targeted mutations for OpenRouter's routing contract.

Core (crates/buzz-agent):

  • Provider::OpenRouter enum variant with OPENROUTER_API_KEY, BUZZ_AGENT_MODELOPENROUTER_MODEL fallback, OPENROUTER_BASE_URL env convention
  • Body mutator: reasoning: {effort} when effort is configured, and max_completion_tokens translated to OpenRouter's max_tokens spelling; no provider.require_parameters filter (it routes only to endpoints advertising every parameter in the body, which hard-404s a valid model id); summaries get neither. openai_body is always called with effort=None on the OpenRouter path — the reasoning object is added by the mutator directly, so reasoning_effort is structurally absent.
  • Attribution headers: HTTP-Referer: https://github.com/block/buzz, X-OpenRouter-Title: Buzz
  • Error-inside-200 check in shared parse_openai (finish_reason == "error")
  • 401 auth handling: static API keys (refresh_now returns the same token) fail terminal immediately with one wire request; PKCE/minting sources get one retry with the fresh token.
  • Status+error_type retry matrix (4-arm collapsed form): 429 (honor Retry-After), 502 (retry), 503/provider_overloaded (honor Retry-After), everything else including untyped 503 (bounded retries → actionable routing message). 499 included matching shared post() (fix(timeout): unified turn-timeout fix — cap inheritance, steer renewal, activity-aware requeue, LLM stall surfacing #2175) for turn-timeout stall surfacing. Terminal failures wrapped in terminal_llm_error for duration+attempt-count context.
  • anthropic/* cache_control injection (model-gated, mixed-content safe)
  • Provider-agnostic reasoning_details opaque round-trip on HistoryItem::Assistant for tool-call continuations — captured verbatim in parse_openai_with_reasoning_details, replayed verbatim in openai_body, byte-accounting charged. provider_extra passthrough from make_tool_call composes independently.

Desktop:

  • Readiness arms checking OPENROUTER_API_KEY + OPENROUTER_MODEL
  • Model discovery via {OPENROUTER_BASE_URL}/models filtered on supported_parameters contains tools
  • Picker entry, credential config, effort table 3-file sync

desktop/src/features/agents/AGENTS.md: no rules changed — the scoped rule requiring an explicit note is satisfied here.

Implements the gate-cleared plan from PLANS/OPENROUTER_PROVIDER_PLAN.md (rev 3).

@wpfleger96
wpfleger96 requested a review from a team as a code owner July 16, 2026 17:13
@wpfleger96
wpfleger96 marked this pull request as draft July 16, 2026 19:25
@wpfleger96
wpfleger96 marked this pull request as ready for review July 26, 2026 21:36
@wpfleger96
wpfleger96 force-pushed the duncan/openrouter-provider branch 3 times, most recently from 1b84513 to 5baa132 Compare July 29, 2026 21:19
@wesbillman

Copy link
Copy Markdown
Collaborator

Carl (AI agent) commenting on Wes’s behalf.

Re-reviewed the current PR head, 5baa132418411f73afe575c74b2b63c56b935e92, against current main, 005b5b819a98ce85d4d80cd81b258fb6f9b8d51e. The blocking issue remains unchanged: this single OpenRouter commit still modifies 50 files and carries 1,861 deletions, silently reverting nine unrelated merged PRs.

Concrete production regressions still present in the current diff:

CI being green does not make these reversions safe: the reverted implementations previously passed CI, and this branch deletes several of the regression tests that would catch them.

The OpenRouter-specific implementation itself looks careful and has strong coverage, but it needs to be rebuilt/rebased so the PR preserves current main and contains only the intended OpenRouter files. Princess Donut’s independent review identified one additional small fix in that clean rebuild: crates/buzz-agent/src/llm.rs:2050 should use OpenRouter’s documented X-Title attribution header rather than X-OpenRouter-Title, and the corresponding assertion should be updated.

Requested change: replace this head with a clean OpenRouter-only diff on current main, preserve all nine unrelated merged changes, correct the attribution header, and request re-review. Please do not merge the current head.

@wpfleger96
wpfleger96 force-pushed the duncan/openrouter-provider branch from 5baa132 to 7ca120a Compare July 29, 2026 21:49
@wesbillman

Copy link
Copy Markdown
Collaborator

Carl (AI agent) commenting on Wes’s behalf.

Re-review update: the earlier blocking comment is fully resolved at head 7ca120a3d5c9350eac6d0358a80fdba6ba28d534.

  • The diff is now limited to the intended 15 OpenRouter files; all nine unrelated reversions are gone.
  • Two independent spot-checks agreed that the corrected diff preserves the previously reviewed OpenRouter implementation and has no remaining correctness blocker.
  • Correction to the earlier attribution note: current OpenRouter documentation uses X-OpenRouter-Title as the primary header and accepts X-Title as an alias. The implementation is correct as written.
  • All required checks on this exact PR head are now complete and green (with Mobile/Web skipped because those paths are untouched).
  • main has advanced and now overlaps in agent.rs, llm.rs, and types.rs via feat(agent,acp): wire provider total_tokens through NIP-AM publish chain #3593, but Git’s current merge-tree resolves the branches cleanly, and GitHub reports the PR mergeable.

No remaining review findings from me. The optional comment documenting Anthropic’s four-cache-breakpoint ceiling remains a maintenance nit only and should not block this PR.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96
wpfleger96 force-pushed the duncan/openrouter-provider branch from 7ca120a to c099f32 Compare July 29, 2026 22:28
@wpfleger96
wpfleger96 enabled auto-merge (squash) July 29, 2026 22:35
@wpfleger96
wpfleger96 merged commit ab55fee into main Jul 29, 2026
52 of 55 checks passed
@wpfleger96
wpfleger96 deleted the duncan/openrouter-provider branch July 29, 2026 23:08
joahg added a commit to joahg/buzz-dev-mode that referenced this pull request Jul 29, 2026
…-style

* origin/main:
  feat: add first-class OpenRouter provider support (block#1975)
  feat(agent,acp): wire provider total_tokens through NIP-AM publish chain (block#3593)

Co-authored-by: Amp <amp@ampcode.com>
Signed-off-by: Joah Gerstenberg <joah@squareup.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019fabca-7cdc-777d-9ccd-ed829c1e60f0

# Conflicts:
#	desktop/src-tauri/src/commands/agent_models.rs
tlongwell-block pushed a commit that referenced this pull request Jul 30, 2026
* origin/main: (29 commits)
  feat(replica): portable heartbeat-token fence with snapshot-local reader routing (#3268)
  fix(git): channel binding tooling + author remediation for unbound repos (#3626)
  feat: configure S3 URL addressing style (#3400)
  feat: add first-class OpenRouter provider support (#1975)
  feat(agent,acp): wire provider total_tokens through NIP-AM publish chain (#3593)
  chore(release): release Buzz Desktop version 0.5.2 (#3624)
  docs: add Linux rendering troubleshooting guide (#3573)
  fix(desktop): discover bun-installed agent CLIs in ~/.bun/bin (#3343)
  feat(tracing): correlate trace IDs in relay logs (#3608)
  chore(ci): bump Linux AppImage build container to ubuntu:24.04 (#3602)
  feat(cli): mirror Desktop mention delivery (#3330)
  fix(desktop): deduplicate relay outage notification (#3579)
  fix(desktop): reconcile thread arrivals at bottom (#3585)
  fix(mobile): keep TLS on relays joined by invite (#3139)
  Improve emoji autocomplete matching (#3571)
  Fix shared agent avatar import profiles (#3578)
  Fix inline raster avatars in agent catalog (#3581)
  revert(acp): remove dead GOOSE_ACP_SCHEDULER_DISABLED env injection (#3576)
  feat(agent): make Gemini and MLflow-route models usable through databricks_v2 (#3569)
  fix(cli): mask credential env values in --help output (#3570)
  ...

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
wpfleger96 added a commit that referenced this pull request Jul 30, 2026
…chive

* origin/main: (22 commits)
  feat(catalog): resolve publisher display name in catalog detail pane (#3640)
  feat(mesh): upgrade embedded mesh to v0.74 and harden shared compute (split 1/2 of #3467) (#3741)
  docs(nips): specify kind:30621 multi-repo projects (NIP-MP) (#3163)
  Refine agent sharing dialog (#3699)
  desktop: enable getUserMedia in the Linux WebKitGTK webview (#3607)
  fix: align responsive agent views (#3688)
  Add macOS agent menu-bar menu (#3565)
  Fix pending message feedback (#3543)
  fix(desktop): remove remaining Projects panel fills (#3742)
  feat(mobile): desktop-parity emoji and thread experience (#3485)
  desktop: restore direct community member adds (#3634)
  fix(desktop): explain open agent access (#2561)
  fix(cli): resolve agents from owner records (#3178)
  fix(desktop): remove Projects overview card fills (#3416)
  feat(replica): portable heartbeat-token fence with snapshot-local reader routing (#3268)
  fix(git): channel binding tooling + author remediation for unbound repos (#3626)
  feat: configure S3 URL addressing style (#3400)
  feat: add first-class OpenRouter provider support (#1975)
  feat(agent,acp): wire provider total_tokens through NIP-AM publish chain (#3593)
  chore(release): release Buzz Desktop version 0.5.2 (#3624)
  ...

Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
wpfleger96 pushed a commit that referenced this pull request Jul 30, 2026
…g-pipeline

* origin/main: (25 commits)
  Refine agent sharing dialog (#3699)
  desktop: enable getUserMedia in the Linux WebKitGTK webview (#3607)
  fix: align responsive agent views (#3688)
  Add macOS agent menu-bar menu (#3565)
  Fix pending message feedback (#3543)
  fix(desktop): remove remaining Projects panel fills (#3742)
  feat(mobile): desktop-parity emoji and thread experience (#3485)
  desktop: restore direct community member adds (#3634)
  fix(desktop): explain open agent access (#2561)
  fix(cli): resolve agents from owner records (#3178)
  fix(desktop): remove Projects overview card fills (#3416)
  feat(replica): portable heartbeat-token fence with snapshot-local reader routing (#3268)
  fix(git): channel binding tooling + author remediation for unbound repos (#3626)
  feat: configure S3 URL addressing style (#3400)
  feat: add first-class OpenRouter provider support (#1975)
  feat(agent,acp): wire provider total_tokens through NIP-AM publish chain (#3593)
  chore(release): release Buzz Desktop version 0.5.2 (#3624)
  docs: add Linux rendering troubleshooting guide (#3573)
  fix(desktop): discover bun-installed agent CLIs in ~/.bun/bin (#3343)
  feat(tracing): correlate trace IDs in relay logs (#3608)
  ...

Signed-off-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
wpfleger96 pushed a commit that referenced this pull request Jul 30, 2026
…-diff-ui

* origin/duncan/restart-diff-rust-core:
  test(desktop): pin the unstamped-agent restart-diff invariant
  feat(desktop): show which config fields need a restart
  fix(git): channel binding tooling + author remediation for unbound repos (#3626)
  feat: configure S3 URL addressing style (#3400)
  feat: add first-class OpenRouter provider support (#1975)

Signed-off-by: npub1g8493u0xfsjrvflg4n08ezd7vec99mnwzlv0qgwpr9d7gvjwhuzqx59rhw <41ea58f1e64c243627e8acde7c89be667052ee6e17d8f021c1195be4324ebf04@buzz.block.builderlab.xyz>
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