Agent chat: OpenCode Go preset with per-model endpoints (#6111)

* agent chat: OpenCode Go preset with per-model endpoints

One preset (https://opencode.ai/zen/go/v1) covers every Go model: each
model is routed to its endpoint family (chat completions, responses,
messages, Gemini), always with the x-opencode-session header Go
requires. Unknown models fall through protocols when Go names the
mismatch; the conversation and tools translate per protocol.

* agent chat: keep Go reasoning metadata, route all listed models (#5656)

* fix agent chat Go endpoints to documented inference routes

* style: collapse long assert in Go routing test (cargo fmt)

* refactor: share Go tool/args helpers, table-driven protocol routing (no behavior change)

* refactor: share GoCallAccum across Go reply parsers (no behavior change)

* refactor: share part/call extractors across Go history converters (no behavior change)

* refactor: share post_to envelope between post and go_post (no behavior change)

* refactor: pass system note into go_responses_input, drop history clone (no behavior change)

* refactor: lazy Gemini name map, shared go_tools, named tool-call cap (no behavior change)

* refactor: share shaped-tool wrapper across Go tool converters (no behavior change)

* fix: set request_timeout_s in Go test setups for rebased main (no behavior change)

* fix: expect ToolsAvailable first in tool-loop tests (matches new event order)

* simplify: reuse tool_arguments, drop restater comments (no behavior change)

---------

Co-authored-by: Julius <julius@localhost>
Co-authored-by: Jom_g <jom_g@users.noreply.github.com>
Co-authored-by: HoloPort <holoport@localhost>
This commit is contained in:
Jomguy2
2026-10-28 12:20:19 +00:00
committed by GitHub
parent 7d9b28e20d
commit 1dba7f7f04
3 changed files with 1291 additions and 31 deletions
+1
View File
@@ -269,6 +269,7 @@ pub const OPENAI_PRESETS: &[ApiPreset] = &[
ApiPreset { name: "LM Studio", base_url: "http://localhost:1234/v1" },
ApiPreset { name: "OpenAI", base_url: "https://api.openai.com/v1" },
ApiPreset { name: "Mammouth AI", base_url: "https://api.mammouth.ai/v1" },
ApiPreset { name: "OpenCode Go", base_url: "https://opencode.ai/zen/go/v1" },
];
/// Anthropic-compatible endpoints people use. The base URL is the one their documentation calls
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -224,7 +224,13 @@ Grok Build also supports `XAI_API_KEY` for users who choose API authentication.
- **Custom command:** any other program that speaks ACP on stdin and stdout, such as
`my-agent --acp`. SolidCraft starts it directly, not through a shell.
- **OpenAI-compatible API:** a preset (Ollama `http://localhost:11434/v1`, LM Studio
`http://localhost:1234/v1`, OpenAI, Mammouth AI `https://api.mammouth.ai/v1`) or a custom URL, the model name, and an optional key.
`http://localhost:1234/v1`, OpenAI, Mammouth AI `https://api.mammouth.ai/v1`, OpenCode Go `https://opencode.ai/zen/go/v1`) or a custom URL, the model name, and an optional key.
OpenCode Go models are routed to their endpoint by themselves (`/responses`,
`/messages` or Gemini for those families, `/chat/completions` for the rest),
each conversation request carrying the session header Go asks for, so one
preset covers every model.
A model the list does not know is retried on the next protocol when Go names
the mismatch.
- **Anthropic-compatible API:** a preset (Anthropic) or a custom URL, for an endpoint that
speaks the Anthropic Messages API (`{base}/v1/messages`). This covers Anthropic itself and
providers that offer an Anthropic-compatible endpoint, such as DeepSeek and Qwen.