Repository navigation
fix(providers): keep a third-party agent's own User-Agent on OpenCode Go - #15453
Merged
diegosouzapw merged 2 commits intoOct 6, 2026
Conversation
OpencodeExecutor.buildHeaders fed the CLI defaults into forwardOpencodeClientHeaders, whose applyCliDefaults replaces every User-Agent that is not a versioned OpenCode CLI. That rewrite exists for the Zen free tier (diegosouzapw#5997), but it ran on the authenticated Go path too, so an agent sending `my-coding-agent/1.0` reached Go as `opencode/<version>` unless synthesis was switched off globally. OpenCode Go's client requirements ask third-party agents to identify themselves with their own user agent, not a generic SDK or HTTP-library name, and to send a stable x-opencode-session. On the Go surface (by registry baseUrl) and outside the free-tier gate, an agent's own UA is now kept; a generic SDK / HTTP-library UA is still replaced and a missing one is still filled. The Zen free-tier policy is unchanged. Closes diegosouzapw#15311
Moves the User-Agent keep/replace decision out of applyCliDefaults into keepsClientUserAgent (no new complexity-ratchet violation) and trims the executor call-site comment so open-sse/executors/opencode.ts stays under its frozen file-size baseline. Behaviour unchanged; covered by the diegosouzapw#15311 and diegosouzapw#5997 header tests.
Contributor
Author
|
CI note for reviewers: The red checks on this PR are inherited from
The checks that exercise this change pass: API Route Typecheck, the other unit-test shards and Vitest. Before pushing I ran the |
diegosouzapw
merged commit Oct 6, 2026
e8a18fc
into
diegosouzapw:release/v3.8.52
43 of 51 checks passed
diegosouzapw
added a commit
that referenced
this pull request
Oct 6, 2026
Follow-up da onda 6. Nenhum código de produto. Tetos medidos no tip depois dos squashes: - `open-sse/executors/opencode.ts` 1518 → 1519 (#15453) - `tests/unit/combo/quota-weighted-strategy.test.ts` novo, congelado em 1217 (#15480) O adopt de i18n grava o hash atual de `README.md` (#15541, #15467) e `docs/reference/ENVIRONMENT.md` (#15542). Não traduz. File-size OK (171 congelados, 47 testes congelados). i18n drift PASS (sources=152, targets=10032).⚠️ base-red inherited: #15306
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #15311
Problem
OpencodeExecutor.buildHeadersfeeds the CLI defaults intoforwardOpencodeClientHeaders. ItsapplyCliDefaultsreplaces every User-Agent that isn't a versioned OpenCode CLI. That rewrite exists for the Zen free tier (#5997, Cloudflare refusing generic UAs from datacenter IPs), but it also ran on the authenticated OpenCode Go path. As a result, a third-party agent sendingmy-coding-agent/1.0reached Go asopencode/<version>unless CLI synthesis was switched off globally.OpenCode Go's client requirements (opencode.ai/docs/go, "Where can I use it?") ask the opposite: a client should
and send a stable
x-opencode-session.Fix
forwardOpencodeClientHeadersgains akeepAgentUserAgentoption. When it is set, a client User-Agent that names the agent itself is kept.isGenericClientUserAgentmatches anchored, bounded SDK / HTTP-library defaults: curl, python-requests/httpx, OpenAI/Anthropic SDKs, axios, node-fetch, undici, Go-http-client, okhttp, Bun and others. Those UAs are still replaced, and a missing UA is still filled.buildHeadersenables the option only on the Go surface (identified by registrybaseUrl, so aliases don't matter) and outside the free-tier gate. The Zen free-tier policy is unchanged.Tests
tests/unit/opencode-go-client-user-agent-15311.test.tscovers:opencode/1.18.31UA is keptR1 and R2 failed before the fix. All OpenCode tests pass after it (850/850), and so do the existing #5997 synthesis tests.
Related
x-opencode-session. That is a different path (buildOpencodeBackgroundHeaders) and doesn't conflict with this generation-path change.Local quality gates
I ran the
quality.ymlfast-gate set locally againstrelease/v3.8.52:keepsClientUserAgent, soapplyCliDefaultsgains no complexity andopencode.tsstays under its frozen size.cyclesandagent-skills-syncfail identically on the untouched base.workflowsneedsactionlintandzizmor, which aren't installed locally.