From e1e97f4649b6c38becd01cd2c4e61f0bb4f52f4f Mon Sep 17 00:00:00 2001 From: songchaow Date: Tue, 9 Jun 2026 19:59:45 +0800 Subject: [PATCH] feat: add X-Session-Id header for Anthropic proxy cache affinity Providers like LLM++ (TimiAI) use X-Session-Id to route requests from the same session to the same upstream account, maximizing KV-Cache hit rate. Without this header, multi-turn conversations get scattered across different upstream accounts, causing frequent cache misses. The header is sent alongside the existing x-session-affinity header for all non-opencode providers. --- packages/opencode/src/session/llm/request.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/opencode/src/session/llm/request.ts b/packages/opencode/src/session/llm/request.ts index 0996be0f7ba4..2785d9852631 100644 --- a/packages/opencode/src/session/llm/request.ts +++ b/packages/opencode/src/session/llm/request.ts @@ -185,6 +185,7 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre } : { "x-session-affinity": input.sessionID, + "X-Session-Id": input.sessionID, ...(input.parentSessionID ? { "x-parent-session-id": input.parentSessionID } : {}), "User-Agent": USER_AGENT, }),