Skip to content

fix(llm): per-model protocol bindings for OpenCode Zen/Go presets - #394

Merged
ModerRAS merged 1 commit into
masterfrom
fix/opencode-multi-binding-presets
Sep 17, 2026
Merged

ModerRAS merged 1 commit into
masterfrom
fix/opencode-multi-binding-presets

Conversation

@ModerRAS

Copy link
Copy Markdown
Owner

Why

opencode-zen / opencode-go presets mapped both gateways to LLMProvider.Anthropic with one AnthropicMessages binding. Neither gateway is Anthropic-only:

  • Go (https://opencode.ai/zen/go/v1) serves /responses (grok-4.6, gpt-5.6-luna) and /chat/completions (glm/kimi/deepseek/longcat/minimax/qwen/mimo) — no Anthropic endpoint at all
  • Zen (https://opencode.ai/zen/v1) is per-model: claude-* → messages, gpt-*/grok-* → responses, gemini-* → Google, everything else → chat completions

As written, a Go preset channel sent Anthropic wire format to an OpenAI-only gateway, and even the Anthropic-compatible path was missing x-opencode-session (the 400 MissingSessionID that #389 fixed for the OpenAI paths).

What

  • LlmProviderPreset gains optional Bindings + ModelBindingRules (prefix → binding) and CatalogIsEntitlement (subscription gateways whose catalog is the entitlement).
  • Preset creation builds the extra bindings (EnsureBinding) and assigns each seeded model to the protocol matched by its name (AssignModelBinding). Zen stays pay-per-token: no auto-seeded models, manual rows untouched.
  • Go seeds the official model list and its refresh path now syncs /models add-only (no soft-deletes), binding discovered models through the same rules.
  • AnthropicMessagesTransport now applies x-opencode-session (per-chat when known, otherwise the global session) — Go's Anthropic-compatible requests no longer fail.
  • New helper methods on IEditLLMConfHelper: EnsureBinding, AssignModelBinding.

Validation

  • dotnet build TelegramSearchBot.sln -c Release → 0 errors
  • TelegramSearchBot.LLM.Test → 294/294 (new: LlmProviderCatalogTests, AnthropicTransportSessionTests)
  • TelegramSearchBot.Test → 446 passed, 1 skipped (new preset flow test)

Notes

The presets mapped both OpenCode gateways to LLMProvider.Anthropic with a single
AnthropicMessages binding, but neither gateway is Anthropic-only:
- Go serves /responses (grok-4.6, gpt-5.6-luna) and /chat/completions
- Zen is per-model: claude-* -> messages, gpt-*/grok-* -> responses,
  gemini-* -> Google, everything else -> chat completions

- LlmProviderPreset gains optional Bindings + ModelBindingRules (prefix -> binding)
  and CatalogIsEntitlement to mark subscription gateways
- preset creation builds the extra bindings and assigns seeded models to the
  protocol matched by their name; Zen stays pay-per-token (no auto-seeded models)
- Go seeds the official model list and refreshes its catalog add-only from
  /models, assigning discovered models through the same rules
- AnthropicMessagesTransport applies x-opencode-session (per-chat when known),
  fixing Go's 400 MissingSessionID on the Anthropic-compatible path
- IEditLLMConfHelper: EnsureBinding + AssignModelBinding helpers
- Tests: LlmProviderCatalogTests, AnthropicTransportSessionTests, preset flow
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 171d70a3-356c-4250-8d97-baa16dc72a5f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

PR Check Report

Summary

Test Results

Platform Status Details
Ubuntu Passed Tests passed, artifacts uploaded
Windows Passed Tests passed, artifacts uploaded

Code Quality

  • Code formatting check
  • Security vulnerability scan
  • Dependency analysis
  • Code coverage collection

Test Artifacts

  • Test results artifacts count: 2
  • Code coverage uploaded to Codecov

Links


This report is auto-generated by GitHub Actions

@ModerRAS
ModerRAS merged commit 87bc22f into master Sep 17, 2026
6 checks passed
@ModerRAS
ModerRAS deleted the fix/opencode-multi-binding-presets branch September 17, 2026 02:19
ModerRAS added a commit that referenced this pull request Sep 17, 2026
Resolve #395 conflicts after #393/#394 were squash-merged:
- LlmProviderCatalog / IEditLLMConfHelper / EditLLMConfHelper / EditLLMConfTest:
  keep the branch side (step 2 + step 3/4 content is the superset)
- GeneralBootstrap: keep master's startup catalog refresh (#393) and re-add the
  providers.json source log from step 3

Validated after merge: build 0 errors; LLM.Test 310/310; main tests 455 passed / 1 skipped
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.

1 participant