Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(opencode): route current Zen Sonnet IDs to Messages

Lucas Oliveira36b5c2736815
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a1b7c83b..ae16bdb4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -120,6 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
handoff are kept. (#1041, #1048)
- The OpenCode provider now selects the published wire API for supported Zen
models: Responses, Anthropic Messages, or OpenAI-compatible Chat Completions.
+ Claude Sonnet 5.5 and the legacy Sonnet 4 ID also use Messages.
Its default model is now `mimo-v2.6-flash`, matching the default Go catalogue;
Claude models require an explicit Zen base URL. Configured base URLs remain
authoritative, with no automatic switching between Go and Zen billing.
diff --git a/crates/ai-memory-llm/src/opencode.rs b/crates/ai-memory-llm/src/opencode.rs
index a94cae7d..d78189b9 100644
--- a/crates/ai-memory-llm/src/opencode.rs
+++ b/crates/ai-memory-llm/src/opencode.rs
@@ -338,8 +338,10 @@ const ANTHROPIC_MESSAGES_MODELS: &[&str] = &[
"claude-opus-4-6",
"claude-opus-4-5",
"claude-sonnet-5",
+ "claude-sonnet-5-5",
"claude-sonnet-4-6",
"claude-sonnet-4-5",
+ "claude-sonnet-4",
"claude-haiku-4-5",
"qwen3.8-flash",
"qwen3.7-max",
@@ -608,7 +610,7 @@ mod tests {
fn anthropic_response_with_content(content: &str) -> serde_json::Value {
json!({
- "model": "claude-sonnet-4-6",
+ "model": "claude-sonnet-5-5",
"content": [{ "type": "text", "text": content }],
"usage": { "input_tokens": 1, "output_tokens": 1 },
})
@@ -778,7 +780,7 @@ mod tests {
let provider = OpenCodeProvider::new_with_base_url(
SecretString::from("sk-test"),
- "claude-sonnet-5",
+ "claude-sonnet-5-5",
format!("{}/zen/v1", server.uri()),
)
.unwrap();
@@ -792,7 +794,7 @@ mod tests {
let requests = server.received_requests().await.unwrap();
assert_eq!(requests.len(), 1);
let body: serde_json::Value = serde_json::from_slice(&requests[0].body).unwrap();
- assert_eq!(body["model"], "claude-sonnet-5");
+ assert_eq!(body["model"], "claude-sonnet-5-5");
assert_eq!(header_value(&requests[0], "x-api-key"), Some("sk-test"));
assert_eq!(
header_value(&requests[0], "user-agent"),
diff --git a/docs/install.md b/docs/install.md
index 4cbc263c..d8647dfa 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -1741,7 +1741,7 @@ If you set only the provider, ai-memory picks a sensible default:
| `AI_MEMORY_LLM_PROVIDER=codex` | `gpt-5.6-luna` | Reuses only `access_token` and `account_id` from Codex's `auth.json`; token renewal is delegated to `codex app-server --stdio`. |
| `AI_MEMORY_LLM_PROVIDER=copilot` | `gpt-5.5` | GitHub Copilot Chat backend. ai-memory stores a GitHub user token in `<data_dir>/auth.json`, exchanges it for a short-lived Copilot API token, and refreshes before expiry. |
| `AI_MEMORY_LLM_PROVIDER=gemini` | `gemini-3.5-flash` | Google's hosted option with a generous free tier. ai-memory disables Gemini 3.5 Flash's default dynamic thinking so hidden thought tokens do not truncate strict JSON. Set `GEMINI_API_KEY` (or `GOOGLE_API_KEY`). |
-| `AI_MEMORY_LLM_PROVIDER=opencode` | `mimo-v2.6-flash` | [OpenCode](https://opencode.ai) cloud API. Defaults to the **Go** endpoint, `opencode.ai/zen/go/v1` — a cost-optimised model subset. Published Responses models, including GPT-5.6 Luna and GPT-6 Luna, use `/responses`; supported Claude and Qwen Messages models use `/messages`; other models retain Chat Completions. For **Zen**'s full catalogue, set `AI_MEMORY_LLM_BASE_URL=https://opencode.ai/zen/v1` plus an `AI_MEMORY_LLM_MODEL` from it, such as `claude-sonnet-5`; the default model id is Go's. Requests identify ai-memory by version and reuse one session header across related attempts. Both endpoints take `OPENCODE_API_KEY` (key from `opencode.ai/auth`). Alias: `opencode-zen` — historical, and it selects Go like the others; the endpoint is chosen by the base URL, not the alias, with no automatic billing-product switch. |
+| `AI_MEMORY_LLM_PROVIDER=opencode` | `mimo-v2.6-flash` | [OpenCode](https://opencode.ai) cloud API. Defaults to the **Go** endpoint, `opencode.ai/zen/go/v1` — a cost-optimised model subset. Published Responses models, including GPT-5.6 Luna and GPT-6 Luna, use `/responses`; supported Claude and Qwen Messages models use `/messages`; other models retain Chat Completions. For **Zen**'s full catalogue, set `AI_MEMORY_LLM_BASE_URL=https://opencode.ai/zen/v1` plus an `AI_MEMORY_LLM_MODEL` from it, such as `claude-sonnet-5-5`; the default model id is Go's. Requests identify ai-memory by version and reuse one session header across related attempts. Both endpoints take `OPENCODE_API_KEY` (key from `opencode.ai/auth`). Alias: `opencode-zen` — historical, and it selects Go like the others; the endpoint is chosen by the base URL, not the alias, with no automatic billing-product switch. |
| `AI_MEMORY_EMBEDDING_PROVIDER=openai` | `text-embedding-3-small` (1536-dim) | 5× cheaper than `-3-large` with marginal recall loss. |
| `AI_MEMORY_EMBEDDING_PROVIDER=openai` + `AI_MEMORY_EMBEDDING_BASE_URL=https://openrouter.ai/api/v1` | `openai/text-embedding-3-small` via [OpenRouter](https://openrouter.ai) | Uses `EMBEDDING_API_KEY`, else reuses `LLM_API_KEY` or `OPENAI_API_KEY`, with the OpenAI-compatible embedding client. |
| `AI_MEMORY_EMBEDDING_PROVIDER=openai` + `AI_MEMORY_EMBEDDING_BASE_URL=https://api.orcarouter.ai/v1` | `openai/text-embedding-3-small` via [OrcaRouter](https://www.orcarouter.ai) | Uses `EMBEDDING_API_KEY`, else reuses `LLM_API_KEY`, with the OpenAI-compatible embedding client. |
diff --git a/docs/llm-providers.md b/docs/llm-providers.md
index 2c895db9..c66245f3 100644
--- a/docs/llm-providers.md
+++ b/docs/llm-providers.md
@@ -92,7 +92,7 @@ allowance rather than per-token billing. Set
catalogue and written plainly (`mimo-v2.5`, `glm-5.3-flash`), not in the
`opencode-go/<model>` form OpenCode's own client config uses. The built-in
default is `mimo-v2.6-flash`, served by Go. When selecting Zen, set
-`AI_MEMORY_LLM_MODEL` to a model from its catalogue, such as `claude-sonnet-5`.
+`AI_MEMORY_LLM_MODEL` to a model from its catalogue, such as `claude-sonnet-5-5`.
The provider preserves the chosen catalogue and does not switch billing products
automatically. Published Responses models, including `gpt-5.6-luna` and
`gpt-6-luna`, use `/responses`; supported Claude and Qwen Messages models use
@@ -116,8 +116,8 @@ For Claude through Zen:
```bash
export AI_MEMORY_LLM_PROVIDER=opencode
export AI_MEMORY_LLM_BASE_URL=https://opencode.ai/zen/v1
-export AI_MEMORY_LLM_MODEL=claude-sonnet-5
-ai-memory llm-test --provider opencode --model claude-sonnet-5 --prompt "Reply with OK"
+export AI_MEMORY_LLM_MODEL=claude-sonnet-5-5
+ai-memory llm-test --provider opencode --model claude-sonnet-5-5 --prompt "Reply with OK"
```
<a id="openrouter"></a>