Skip to content

fix(core): restore session request headers - #43188

Merged
neriousy merged 1 commit into
devfrom
session-headers
Aug 18, 2026
Merged

fix(core): restore session request headers#43188
neriousy merged 1 commit into
devfrom
session-headers

Conversation

@neriousy

Copy link
Copy Markdown
Contributor

Summary

  • restore x-session-affinity and X-Session-Id on V2 core runner provider requests
  • include x-parent-session-id for child sessions
  • preserve the correlation headers on compaction provider requests

The dedicated v2 branch already has this behavior from #36975. This ports the missing behavior to dev, whose shared core runner is used by the affected current releases.

Closes #42694

Validation

  • bun test test/session-runner.test.ts in packages/core (87 passed)
  • bun test in packages/core (1091 passed)
  • bun typecheck in packages/core
  • pre-push workspace typecheck (30 packages)

@neriousy neriousy self-assigned this Aug 18, 2026
@neriousy
neriousy merged commit 0033bb3 into dev Aug 18, 2026
11 checks passed
@neriousy
neriousy deleted the session-headers branch August 18, 2026 19:27
alltomatos pushed a commit to alltomatos/opencode that referenced this pull request Aug 18, 2026
1056674754 added a commit to 1056674754/opencode that referenced this pull request Aug 31, 2026
Upstream v1.18.18 (31406cc) -> v1.18.19 (2b72179), 70 commits.

Functional changes:
- feat(opencode): native OpenAI and Anthropic passthroughs for Cloudflare AI Gateway (anomalyco#42634)
- fix(core): fall back on oversized websocket requests (anomalyco#43099)
- fix: codex data residency (anomalyco#42432); match codex limits for openai models on chatgpt subscription (anomalyco#39082)
- fix(core): preserve unicode in grep previews (anomalyco#42356)
- fix(opencode): preserve v1 database compatibility (anomalyco#42444)
- fix(core): restore session request headers (anomalyco#43188)
- fix(opencode): enable web search for Go (anomalyco#42630)
- fix(session): ignore malformed model costs (anomalyco#43248)
- fix(opencode): properly show authed providers on /connect command (anomalyco#39915)
- fix(opencode): remove Qwen sampling defaults (anomalyco#43310)
- fix(provider): update Google Vertex SDK (anomalyco#43108)
- fix(cli): update default console URL (anomalyco#43043)

Conflicts resolved: 29 package.json version bumps (rebranded 1.18.19-sscity),
bun.lock (took upstream, rebranded workspace entries via bun install).
provider.ts, transform.ts, session.ts, tool/registry.ts, and transform.test.ts
auto-merged cleanly: fork ProviderSnapshot refactor, GLM/ZhiPu normalization,
tool registry hot reload, and session fixes are untouched; upstream Cloudflare
passthrough (cloudflareGatewayNpm + native openai/anthropic routes), Qwen
sampling removal, getUsage cost tolerance, and opencode-go websearch adopted
alongside. v1.18.17 retry composition and v1.18.18 provider patches remain
intact.
filipeforattini added a commit to reddb-io/redcode that referenced this pull request Sep 5, 2026
filipeforattini added a commit to reddb-io/redcode that referenced this pull request Sep 5, 2026
1a1a11a added a commit to HarvardMadSys/hybridInference that referenced this pull request Sep 6, 2026
Neither client showed a session in the console. Both were checked against
their own source rather than guessed at, and there were three causes.

Current OpenCode stamps every request to a provider it does not recognise
as its own with both X-Session-Id and x-session-affinity, set to the same
ses_... id, plus x-parent-session-id on a subagent run; on its own provider
it sends x-opencode-session instead. Kilo Code is an OpenCode fork and
builds the same block. X-Session-Id was already the canonical source, so
current builds were handled all along; the affinity and own-provider
spellings are added beside it so one arriving without the other still names
the session. x-parent-session-id is deliberately not read -- it names the
session that spawned this one, and reading it would merge every subagent run
into its parent.

The header block lives in two runners. The newer one lost it and only got it
back in anomalyco/opencode#43188 on 2026-08-18, and Kilo's vendored copy of that
file still has no header block. On that path nothing on the wire names the
session, and the gateway records none rather than inferring one from a field
that was not meant to carry it.

Neither client was even labelled, in two places. Their LLM requests identify
as opencode/<version> and kilo/<channel>/<version>/<client>, which matched
nothing in the console's parseClientTool nor in the copy of that table in
analytics/automation_score.py -- so both fell through to the leading-token
label and drew the unknown automation prior of 0.6 instead of the interactive
0.1, skewing their users' automation scores. Both tables now match, with the
real user-agent shapes covered by tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpETEerrhcCpsg69ucjrEt
1a1a11a added a commit to HarvardMadSys/hybridInference that referenced this pull request Sep 6, 2026
Follow-up to #1371, correcting guidance that was wrong there.

The console still showed no session for OpenCode and Kilo after #1371 reached
staging. Claude Code and Codex rows do carry sessions, so the gateway side
works end to end and the gap is entirely client-side.

#1371 said to add a chat.headers plugin on the runner that sends no headers.
That is useless in both directions. The hook exists only on the older
packages/opencode/src/session/llm/request.ts path, which already builds the
header block itself; the newer core runner
(packages/core/src/session/runner/llm.ts, registered as SessionRunnerLLM.node
in location-services.ts) has neither the header block nor any plugin hook.
Where the hook exists nothing needs fixing, and where the headers are missing
there is nothing to hook.

Both paths were checked against the sst/opencode and Kilo-Org/kilocode trees
rather than inferred. The text now names them and the registration site so a
reader can confirm it quickly, and gives the two real remedies: upgrade
OpenCode past anomalyco/opencode#43188, and port that same change into the Kilo
fork, which branched before the restore.

Docs only. The zh_CN catalog carries both rewritten paragraphs.

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

Projects

None yet

1 participant