GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(opencode): every OpenCode request now carries x-opencode-session for backend affinity (#81584) by teknium1 · Pull Request #101864 · NousResearch/hermes-agent

Conversation

@teknium1

@teknium1 teknium1 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Every request Hermes sends to OpenCode (Zen / Go / Free, and custom providers pointing at opencode.ai) now carries an opaque, per-conversation x-opencode-session header, on every transport and on auxiliary calls too. OpenCode uses it to pin a conversation to one backend so its prompt cache stays warm; without it, cache ratios on Hermes traffic were poor (reported directly by the OpenCode team) and some Go backends 400'd outright (#81584, #81832).

Changes

  • agent/opencode_affinity.py (new, ~80 LOC): single owner of target detection (opencode_provider_family + opencode.ai host) and the key. Key resolution matches the OpenRouter sticky session_id / xAI x-grok-conv-id hints: declared affinity scope → conversation root → physical session_id, cron per-fire timestamp stripped.
  • agent/chat_completion_helpers.py: build_api_kwargs merges the header once after the per-mode builder → chat_completions, codex_responses, anthropic_messages all covered with one site.
  • agent/auxiliary_client.py: _build_call_kwargs adds the same key from the runtime-main session (compression / titles / vision / MoA stay on the conversation's backend); the aux Codex and Anthropic adapters now forward extra_headers (previously dropped on the floor).
  • website/docs/integrations/providers.md: one paragraph documenting the header.
  • 2 invariant tests (tests/agent/test_opencode_session_affinity.py).

Validation

Path Before After
main turn, go / chat_completions (glm-5) no header x-opencode-session: <session>
main turn, go / codex_responses (gpt-5.6-luna) no header same value
main turn, go / anthropic_messages (minimax-m2.7) no header same value
main turn, zen + free + custom-URL-only no header same value
aux _build_call_kwargs (compression etc.) no header same value as main turn
openrouter (negative) no header no header
Live wire (keyless free tier, httpx request hook) — POST https://opencode.ai/zen/v1/chat/completions carried x-opencode-session: sess-live-77, 200 OK

Targeted suites: 242 + 305 passed (opencode profile/free/headers, aux client, codex/anthropic transports, prompt caching, attribution headers). ruff clean.

Supersedes #81591 (@chelsealong) — that PR covered opencode-go only and re-derived the key in three places; this generalizes to all OpenCode providers + aux path with one owner. Credit to chelsealong for the original diagnosis.

Closes #81584
Closes #81832

Infographic

x-opencode-session: one conversation, one backend

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

oddm643, francesqwo, msegoviadev, krishpuri, achourk, pymq, iberi22, and JoyousJohn reacted with heart emoji
All reactions
  • ❤️ 8 reactions
@teknium1
feat(opencode): send x-opencode-session on every OpenCode request for…
c9e2075
… backend affinity

OpenCode pins requests sharing an x-opencode-session value to one upstream
backend, which is what keeps its prompt cache warm across a conversation.
Hermes never sent it, so cache ratios on OpenCode traffic were poor.

- agent/opencode_affinity.py: single owner of the header — target detection
  (built-in zen/go/free, custom opencode-* providers, any opencode.ai URL)
  and the key (affinity scope → conversation root → session id, cron
  timestamp stripped), same resolution as OpenRouter/xAI affinity hints.
- build_api_kwargs: merged once after the per-mode builder, so
  chat_completions, codex_responses and anthropic_messages all carry it.
- auxiliary _build_call_kwargs: same key from the runtime-main session so
  compression/title/vision calls stay on the conversation's backend; the
  aux Codex and Anthropic adapters now forward extra_headers.

Closes #81584, #81832 (deepseek-v4-flash 400 without the header).
@github-actions

github-actions Bot commented Sep 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on c9e2075 — feat(opencode): send x-opencode-session on every OpenCode re

⚠️ Warnings

OSV vulnerability scan · View job

28 known vulnerabilities found in pinned dependencies.

  • CVE-2026-67213 in website/package-lock.json
  • CVE-2026-82417 in scripts/whatsapp-bridge/package-lock.json
  • CVE-2026-82417 in website/package-lock.json
  • CVE-2026-75931 in package-lock.json
  • CVE-2026-75931 in website/package-lock.json
  • CVE-2026-83610 in package-lock.json
  • CVE-2026-83610 in package-lock.json
  • CVE-2026-71554 in uv.lock
  • CVE-2026-73088 in package-lock.json
  • CVE-2026-73088 in website/package-lock.json
  • GHSA-8423-8fgw-73vq in uv.lock
  • CVE-2026-70608 in package-lock.json
  • CVE-2026-73089 in package-lock.json
  • CVE-2026-73089 in website/package-lock.json
  • CVE-2026-75975 in package-lock.json
  • CVE-2026-75975 in website/package-lock.json
  • CVE-2026-75899 in package-lock.json
  • CVE-2026-75899 in website/package-lock.json
  • CVE-2026-84371 in package-lock.json
  • CVE-2026-56876 in package-lock.json

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 4m28s vs 4m7s (+8.5%). 7 job(s) slower, 7 faster, 1 unchanged.

  • OS-specific tests / Windows-only tests: +22.0s
  • OS-specific tests / macOS-only tests: +11.0s
  • Python tests / e2e: +7.0s
  • Python tests / Run tests: -4.0s
  • Profile artifact check / Reject profile archives: -3.0s
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Sep 3, 2026
@alt-glitch

alt-glitch commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Supersedes #81591's narrower OpenCode Go-only repair: this implementation covers all OpenCode target detection, every main transport, and auxiliary calls.

JoyousJohn reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@teknium1
teknium1 merged commit 1393969 into main Sep 3, 2026
40 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@teknium1
teknium1 deleted the hermes/hermes-e2fa55cb branch September 3, 2026 04:46
@teknium1 teknium1 mentioned this pull request Sep 3, 2026
fix(opencode-go): send x-opencode-session header for session affinity #81591
Closed
9 tasks done
@MrPaulAR MrPaulAR mentioned this pull request Sep 3, 2026
[FEAT]: Add x-opencode-session Header Mintplex-Labs/anything-llm#6283
Open
@HasNate618 HasNate618 mentioned this pull request Sep 3, 2026
[Feature]: forward x-opencode-session on opencode requests maximhq/bifrost#6815
Closed
1 task done
@jake-101

jake-101 commented Sep 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

can there be a point release for this? i've never updated to a random commit before. i got an email i have to send this header by September 6th or I'll experience errors.

pymq reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Du7chManiac

Du7chManiac commented Sep 3, 2026

Copy link
Copy Markdown

can there be a point release for this? i've never updated to a random commit before. i got an email i have to send this header by September 6th or I'll experience errors.

Running hermes update will update to latest commit so it will include this. You can also ask hermes to update itself.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zhd1254 zhd1254 mentioned this pull request Sep 4, 2026
feat: Allow custom HTTP headers on LLM provider requests (needed for x-opencode-session) rohitg00/agentmemory#1328
Open
@jake-101

jake-101 commented Sep 4, 2026

Copy link
Copy Markdown

can there be a point release for this? i've never updated to a random commit before. i got an email i have to send this header by September 6th or I'll experience errors.

Running hermes update will update to latest commit so it will include this. You can also ask hermes to update itself.

yeah i went ahead and updated to this commit. it wasnt that hard but i'll go back to a versioned release when possible.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Haderach-Ram Haderach-Ram mentioned this pull request Sep 4, 2026
Ecosystem Digest — 2026-09-04 Haderach-Ram/openclaw-radar#131
Open
@RaajeevChandran RaajeevChandran mentioned this pull request Sep 7, 2026
added x-opencode-session affinity header for opencode hosts osaurus-ai/osaurus#2666
Merged
1 of 9 tasks
@H3xKatana

H3xKatana commented Sep 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

this wont work with docker / container deployments a new image release is needed

can there be a point release for this? i've never updated to a random commit before. i got an email i have to send this header by September 6th or I'll experience errors.

Running hermes update will update to latest commit so it will include this. You can also ask hermes to update itself.

mattegoghero-eng, Mattszczp, gogokimc, and ClixStudios reacted with thumbs up emoji
All reactions
  • 👍 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KagamiChan KagamiChan mentioned this pull request Sep 7, 2026
fix(opencode): restore automatic affinity for named custom gateways #105099
Open
@IAkumaI IAkumaI mentioned this pull request Sep 7, 2026
[Bug] OpenAI-compatible LLM provider cannot send per-session x-opencode-session (OpenCode Go 400 MissingSessionID) volcengine/OpenViking#4782
Closed
@jluzny jluzny mentioned this pull request Sep 7, 2026
Max-iterations summary builders omit x-opencode-session → relay 400 MissingSessionID on anthropic_messages/chat_completions OpenCode models #105132
Open
shuv1337 added a commit to shuv1337/hermes-agent that referenced this pull request Sep 7, 2026
@shuv1337
feat(opencode): send x-opencode-session on every OpenCode request for…
1939906
… backend affinity

Port of upstream PR NousResearch#101864 (1393969). OpenCode Go now 400s requests
that omit x-opencode-session; the header also pins a conversation to one
backend so prompt cache stays warm.

- agent/opencode_affinity.py: single owner of target detection and the key
- build_api_kwargs: merge once after the per-mode builder so every transport
  carries it
- auxiliary _build_call_kwargs: same key from the runtime-main session;
  Codex/Anthropic aux adapters now forward extra_headers

A full upstream merge is 5514 commits behind; this ports the isolated fix.
@analogpotato analogpotato mentioned this pull request Sep 8, 2026
opencode: iteration-summary requests omit x-opencode-session -> Console Go 400 MissingSessionID #105504
Open
@shira022 shira022 mentioned this pull request Sep 8, 2026
fix(opencode): inject x-opencode-session into SDK client default_headers #105526
Closed
@killo3967 killo3967 mentioned this pull request Sep 9, 2026
[Bug]: opencode-zen free-tier models 429 FreeUsageLimitError with bundled HermesAgent headers — only opencode UA + X-Session-ID returns 200 (0.21.1) #106495
Closed
@moemcb moemcb mentioned this pull request Sep 9, 2026
v0.2.6: Built-in OpenCode Go provider doesn't send x-opencode-session (routing rejected since 2026-09-05) s0ld13rr/pentestcode#13
Closed
@EKKOLearnAI EKKOLearnAI mentioned this pull request Sep 10, 2026
fix: send OpenCode session headers from Studio providers EKKOLearnAI/ekko-studio#2996
Merged
@Finn763 Finn763 mentioned this pull request Sep 10, 2026
fix(providers): send opencode-compatible headers on zen free-tier routes #107737
Closed
Finn763 added a commit to Finn763/hermes-agent that referenced this pull request Sep 10, 2026
@Finn763
fix(providers): send opencode-compatible headers on zen free-tier routes
d4083f7
The Zen relay's free tier (https://opencode.ai/zen/v1, keyless) answers HTTP 429
FreeUsageLimitError to Hermes' canonical attribution headers (User-Agent:
HermesAgent/<v> + the hermes-agent referer/title) while the same model returns 200
to the OpenCode client fingerprint. NousResearch#101864's x-opencode-session fixed the
MissingSessionID 400 and stands; only the client default_headers identity was
never switched.

- hermes_cli/opencode_client_headers.py: stdlib-only leaf module owning the
  fingerprint (UA opencode/0.20.5, referer https://opencode.ai/, title opencode,
  opaque X-Session-ID), shared by the runtime header set and the provider profile
  so the two copies cannot drift.
- hermes_cli/models.py: opencode_zen_free_headers() returns the fingerprint plus
  the empty Authorization that keeps the keyless placeholder off the wire.
- plugins/model-providers/opencode-free: the profile's default_headers read that
  same module instead of duplicating the Hermes values.
- agent/agent_runtime_helpers.py: key the header set off the keyless placeholder,
  not the provider name, so a free slug picked under opencode-zen/go (healed onto
  the same keyless Zen route) gets it too.

Keyed Zen/Go keep the Hermes attribution and never send X-Session-ID;
x-opencode-session still rides on every OpenCode request, so both header policies
coexist.

Tests: wire-level mock guard
tests/run_agent/test_opencode_zen_free_wire_headers.py (red on main, green after
the fix, bites under sabotage) plus the updated free-tier header assertions.
vuralozsen added a commit to vuralozsen/hermes-agent that referenced this pull request Sep 11, 2026
@vuralozsen
fix(opencode): send x-opencode-session on every OpenCode request (por…
aeb1d74
…t of upstream PR NousResearch#101864)

opencode-go returns HTTP 400 MissingSessionID on real multi-message
conversations without the header. Ported:
- agent/opencode_affinity.py (new): header derivation per conversation
- chat_completion_helpers.build_api_kwargs: wrap mode builder, merge header
- auxiliary_client: forward extra_headers on Codex + Anthropic aux adapters

E2E: 4-msg probe without header -> 400; with header -> 200.
@maikolb maikolb mentioned this pull request Sep 16, 2026
feat(nfos): opt-in DeepSeek workers from Telegram maikolb/hermes-agent#203
Merged
@sentic-binary sentic-binary mentioned this pull request Sep 16, 2026
Auxiliary calls not sending x-opencode-session header to opencode-zen #112704
Closed
@realAbitbol realAbitbol mentioned this pull request Sep 19, 2026
fix(opencode): preserve custom provider identity for session affinity (salvage #105099) #116203
Closed
11 of 12 tasks
@ar27111994 ar27111994 mentioned this pull request Oct 1, 2026
[Feature]: mem0 memory provider cannot use OpenCode Go (mem0 LLM client can't send x-opencode-session) #130473
Closed
1 task
@pyxl-dev pyxl-dev mentioned this pull request Oct 2, 2026
fix(opencode): preserve session affinity across fallback and compression pyxl-dev/hermes-agent#1
Open
vuralozsen added a commit to vuralozsen/hermes-agent that referenced this pull request Oct 5, 2026
@vuralozsen
merge: take upstream side for the 3 opencode files (fork port was a b…
9b1205b
…ackport of upstream PR NousResearch#101864; upstream main already contains its own evolved copy)
@timfewi timfewi mentioned this pull request Oct 5, 2026
fix: preserve model session metadata in the LLM broker timfewi/tentaflake#134
Merged
10 of 16 tasks
@kfwebdev kfwebdev mentioned this pull request Oct 8, 2026
opencode.ai returned HTTP 400: Request is missing x-opencode-session odysseus-dev/odysseus#6606
Open
3 tasks done
@RecursiveIntell RecursiveIntell mentioned this pull request Oct 15, 2026
fix(opencode): restore session-bound provider affinity RecursiveIntell/Ares#167
Merged
@sc28249782 sc28249782 mentioned this pull request Oct 18, 2026
opencode-go provider: requests missing x-opencode-session cause 400 MissingSessionID on OpenCode Go thClaws/thClaws#228
Closed
@opencodejr opencodejr Bot mentioned this pull request Oct 28, 2026
OpenCode-Go 自称 OpenAI Compatible,但强制额外私有 Header,对第三方客户端极不友好;文档提示不足,用户调试成本过高 anomalyco/opencode#50877
Closed
@jaredwang jaredwang mentioned this pull request Oct 30, 2026
请求支持 OpenCode Go:能拉到模型列表,对话报 missing x-opencode-session (INVALID_REQUEST) jackwener/DSH-Android#32
Closed
@skoch13 skoch13 mentioned this pull request Nov 17, 2026
Support OpenCode Go session headers for OpenAI-compatible inference karakeep-app/karakeep#3386
Open
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: Deepseek v4 Flash via Opencode Go not working - rejects deepseek-v4-flash even though it reports it as supported [Bug]: OpenCode Go deepseek-v4-flash fails with 400 "Model is unavailable" unless x-opencode-session is sent

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@teknium1 @alt-glitch @jake-101 @Du7chManiac @H3xKatana
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.