Skip to content

feat: send x-opencode-session header for OpenCode Go/Zen providers - #5868

Open
huangxianzhan wants to merge 1 commit into
Hmbown:mainfrom
huangxianzhan:feat/opencode-session-header
Open

feat: send x-opencode-session header for OpenCode Go/Zen providers#5868
huangxianzhan wants to merge 1 commit into
Hmbown:mainfrom
huangxianzhan:feat/opencode-session-header

Conversation

@huangxianzhan

Copy link
Copy Markdown
Contributor

What

OpenCode Go (https://opencode.ai/docs/go/) asks clients to send a stable \x-opencode-session\ header so it can optimize prompt caching and attribute traffic to a conversation. Codewhale requests were missing it, and the client UA (Mozilla/5.0 compatible codewhale/...) gets classified as a plain browser on the gateway; traffic without the header may error starting 2026-09-06.

Changes

  • Inject one process-stable UUID v4 into \x-opencode-session\ in \�uild_default_headers\ for \OpencodeGo/OpencodeZen\ providers only.
  • Other providers are untouched; a user-configured \x-opencode-session\ via the existing \http_headers\ config always wins (extra-header loop overwrites).
  • Three unit tests: header present and stable per process; user-configured value wins; absent for non-OpenCode providers.

Verification

  • \cargo check -p codewhale-tui\ passes
  • \cargo test -p codewhale-tui --lib session_header: 3 passed, 0 failed
  • End-to-end capture against a local mock gateway shows the header on every request; live opencode.ai models/chat/SSE behave normally.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thanks @huangxianzhan for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

Replaces the earlier commit whose blob carried CRLF line endings, producing
a noisy full-file diff. Same code: process-stable x-opencode-session UUID v4
for OpencodeGo/OpencodeZen in build_default_headers, user-configured header
wins, three unit tests.
@huangxianzhan
huangxianzhan force-pushed the feat/opencode-session-header branch from 7faf58e to 4a2d296 Compare September 4, 2026 02:45
Garfield1985 pushed a commit to Garfield1985/DeepSeek-TUI that referenced this pull request Sep 5, 2026
The OpenCode Go and Zen gateways ask clients for a stable
`x-opencode-session` header so the service can optimize prompt caching and
attribute traffic to one conversation. One UUID v4 per process gives every
request from a session the same id; a user-configured header of the same
name still wins, because the extra-header loop runs after this insert.

Harvested rather than merged: the submitted branch had `client.rs` saved with
CRLF line endings, so a 98-line change arrived as a 24,000-line whole-file
rewrite that would have flipped the file's line endings for every other
contributor. This is the author's exact change and their test, applied to the
LF file. `client.rs` was untouched on main since their branch point, so the
normalized content is theirs line for line.

Their test `opencode_go_and_zen_requests_carry_stable_session_header` passes
(1/1), asserting both that the header is present for each gateway and that a
second request from the same process reuses the id.

Gates: cargo fmt --all --check CLEAN · nextest -p codewhale-tui
test(opencode) 18 passed / 0 failed.

Co-authored-by: huangxianzhan <264075734+huangxianzhan@users.noreply.github.com>
Harvested-from: PR Hmbown#5868 by @huangxianzhan
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QCLLenseqfQdVaZUBqn9yG
Garfield1985 pushed a commit to Garfield1985/DeepSeek-TUI that referenced this pull request Sep 5, 2026
0.9.12 had no `### Contributors` section, `web/lib/release-credits.ts`
still held the 0.9.11 cohort, and the contributor doc band was missing
five people whose work landed. Three surfaces that must agree, disagreeing
three ways.

Everyone whose work reached main this cycle is now named in all three,
derived from `Co-authored-by` and `Harvested-from` trailers on
v0.9.11..HEAD rather than from memory. The five who were missing:

- @qiuYliangM (秋月凉梦) — co-author on Hmbown#5621, Hmbown#5622, Hmbown#5623
- @whp233Hmbown#5716, landed as Hmbown#5719
- @Gabriel-DegretHmbown#5867
- @huangxianzhanHmbown#5868
- @zhuowpHmbown#5869

@aboimpinto's entry gained Hmbown#5825 and Hmbown#5865, @M-Maciej's gained Hmbown#5533/Hmbown#5831.

`requiredCandidateCredits` in public-surface-facts.json moves from the
0.9.11 cohort to this one — that guard is meant to hold the *current*
release's credits in every surface, and it had been pinning the previous
release's.

`RELEASE_HELPERS` is deliberately empty. Every credited contribution this
cycle arrived as code that landed; a name there that no landed change can
point at would be a nicer-looking ledger and a less true one.

AUTHOR_MAP gains canonical numeric-noreply identities for all five, since
the trailers on their harvest commits used raw emails and old-style
noreply addresses.

web: 386 tests, 386 passed. check:facts, check:docs, check:tokens,
check:locales all PASS.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QCLLenseqfQdVaZUBqn9yG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant