Repository navigation
Replies: 2 comments
|
The successful request after adding x-opencode-session is a strong indication that the web-search adapter is missing session-specific routing information rather than the gateway itself being incompatible. I'd separate the problem into two parts:
If the current session already has a resolved LLM route, the web-search implementation could reuse that route when it is compatible with the search tool instead of always falling back to the DeepSeek endpoint. For gateways such as OpenCode Go that require session affinity, the adapter should also allow provider-specific routing headers such as x-opencode-session to be supplied. I would avoid hardcoding OpenCode-specific behavior into the generic web-search implementation. A better design would be for the selected provider/route to expose the required headers or request context, with the web-search adapter simply forwarding them. A regression test using a mock Anthropic-compatible gateway that requires x-opencode-session would be useful here. It could verify both that the session route is selected and that its required routing headers reach the request. If this clears up the issue, please consider marking the answer as accepted so others who run into the same problem can find the solution more easily. |
|
Thanks — the diagnosis matches what I could reproduce on Reproduction (Desktop 0.2.0-rc.2, macOS arm64, session route
|
Uh oh!
There was an error while loading. Please reload this page.
Environment: DSH Desktop
0.2.0-rc.2, macOS arm64, bundled runtime0.2.0-rc.2(hostProtocolVersion 4), LLM routeopencode-gothrough@deepseek-ai/dsh-llm-pi-ai/@earendil-works/pi-ai0.87.1, web search providerdeepseek-official(@deepseek-ai/dsh-web-search-deepseek).What I expected
With the conversation served by OpenCode Go (
https://opencode.ai/zen/go), web searches would go through the same route I am paying for, and only sessions running on a DeepSeek route would search throughapi.deepseek.com.What actually happens
Searches always go to
https://api.deepseek.com/anthropic/v1/messageswithDEEPSEEK_API_KEY, regardless of the session's LLM provider. So a conversation billed to a third-party gateway still spends DeepSeek API credit on everyweb_search— and each search is a full auxiliary model turn (in my probes: ~6.8k input / ~0.9k output tokens per search).Pointing it at OpenCode Go fails on exactly one header
Config attempt:
Result:
HTTP 400, error typeMissingSessionID:The same request with an
x-opencode-session: <id>header added:HTTP 200, content blocksthinking, server_tool_use, web_search_tool_result, thinking, text— 10 results,usage: {input_tokens: 6769, output_tokens: 896, server_tool_use: {web_search_requests: 1}}. Verified for bothdeepseek-v4.1-flashand the provider's defaultdeepseek-v4-flash.So the gateway does implement the native
web_search_20250305server tool; the only missing piece is the routing header.There is no way to supply it today:
apiKey | apiKeyEnv | baseURL | model | apiVersion | maxTokens | maxUses, and the request headers are fixed (x-api-key,authorization,anthropic-version,content-type,accept,user-agent);Worth noting the asymmetry: the chat path already sends this header —
withOpenCodeSessionHeaderin pi-ai (dist/providers/opencode-headers.js, "Adds OpenCode's required per-conversation routing header before API dispatch"). The requirement is known on the LLM route but not on the search route.Two proposals (independent, either one unblocks me)
headers: { x-opencode-session: ... }, ideally with values resolvable from the credentials store the same wayapiKeyEnvis. That unblocks any gateway requiring routing or affinity headers, without hardcoding vendor knowledge.resolveAccountTokenreturns nothing unlesssession.requestContext().provider === "deepseek-account". Generalizing that rule to: "if the session's route is an Anthropic-compatible Messages endpoint that supportsweb_search_20250305, search through that route using its base URL, credential and headers; otherwise fall back to the current DeepSeek default" would match the mental model that search belongs to whichever model/account the conversation runs on. It would also make the 0.2.0-rc.1 improvement ("no extra API key needed for web search") apply to non-DeepSeek routes by construction, instead of only to account-model sessions.Happy to test a patch or a new config field on 0.2.0-rc.2 and report back.
All reactions