[Bug] OpenCode requests lack x-opencode-session and a specific User-Agent required by the Go docs #2072
Closed
cabrinha
started this conversation in
Bug reports
Replies: 3 comments
|
i am using a custom plugin to workaround this issue for now https://github.com/inxeoz/prime-agent-ext/blob/master/x-opencode-session.ts |
0 replies
|
I’m taking a look at this. |
0 replies
|
Merged in #2131; this fix is not released yet. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
AI providers and models
What happened?
The OpenCode Go docs (https://opencode.ai/docs/go/#where-can-i-use-it) state that Go traffic is monitored, and that to avoid an account being flagged the client must (1) identify itself with a specific User-Agent ("no broad user agents") and (2) send the
x-opencode-sessionheader so Go can optimize prompt caching.Prime Agent does neither for
opencode/opencode-gomodels:User-Agentis the SDK default (OpenAI/JS ...on the Responses/Completions paths).x-opencode-sessionis never sent.Impact for Go subscribers: worse prompt-cache hit rate, which burns the dollar-based Go allowance ($12 / 5h, $30 / week, $60 / month) faster, plus a risk of the account being flagged for unidentified traffic.
Reference: OpenCode's own client (
anomalyco/opencode,packages/opencode/src/session/llm/request.ts) sendsx-opencode-session: <sessionID>andUser-Agent: opencode/<version>for every provider id starting withopencode.Prior art in this repo:
f0ebb327f fix(ai): set default Kimi Coding user agent closes #3586set a provider-specific User-Agent via staticheadersforkimi-coding. The same pattern fits here, plus a dynamicx-opencode-sessionfrom the existingsessionIdplumbing increateClientofopenai-responses.ts,openai-completions.ts, andanthropic.ts.Workaround today: provider
headersin~/.prime/agent/models.jsonwith"x-opencode-session": "!uuidgen". That gives one id per process, not per session, and does not distinguish subagent sessions.Steps to reproduce
opencode-goprovider (OPENCODE_API_KEY).~/.prime/agent/models.json, point theopencode-goproviderbaseUrlat a local request-capturing proxy (for examplemitmproxyornc -l 8080) that forwards tohttps://opencode.ai/zen/go/v1.opencode-go/muse-spark-1.3-contributor(Responses API) and send a prompt.opencode-go/deepseek-v4-flash(Completions API) andopencode-go/minimax-m3(Anthropic Messages API).Expected behavior
For every request to an
opencodeoropencode-gomodel, on all three API paths:x-opencode-session: <prime-agent session id>(the same id already used forsession_id/prompt_cache_key), distinct per session including RLM subagent sessions.User-Agent, e.g.prime-agent/<version>, instead of the SDK default.Headers need not be added for non-OpenCode providers.
Prime Agent version
0.9.2
Installation method
Stable release installer
Operating system
macOS
Operating system version
macOS 26.6.2
CPU architecture
arm64 / aarch64
Shell and terminal
zsh, ghostty
Additional context
No response
All reactions