vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Send x-opencode-session header on API requests (required by OpenCode Go from 09/05)

Open thdxr opened this issue 2 months ago • 34 comments

Hi — we operate the OpenCode Go managed-inference API, and 1685 of your users' orgs call it through GitHub Copilot Chat (UA GitHubCopilotChat/0.63.0).

Starting 09/05, requests without an x-opencode-session header will error on our side — we need a stable per-conversation ID for routing/optimization. Copilot Chat doesn't send it in any version we've seen.

Ask: include x-opencode-session: <stable-id-per-conversation> on all outbound inference HTTP requests. Any stable UUID per conversation works. Happy to confirm from our telemetry once a build ships it. Thanks!

thdxr avatar Sep 03 '26 06:09 thdxr

Now I'm totally stucked because of this new requirement when using GitHub Copilot CLI and VS Code 😥

arisng avatar Sep 07 '26 04:09 arisng

????????????????????????????????????????

wjchen94 avatar Sep 07 '26 05:09 wjchen94

opencode is such a shit model provider!!! You completely break down service BEFORE solving this issue??? What's the problem with you???

wjchen94 avatar Sep 07 '26 05:09 wjchen94

so bad, I also meet this error

gaaralbakuu avatar Sep 07 '26 07:09 gaaralbakuu

Now I'm totally stucked because of this new requirement when using GitHub Copilot CLI and VS Code 😥

You may use my extension. I have already fixed it.

OnesoftQwQ avatar Sep 07 '26 07:09 OnesoftQwQ

I think the best solution will be that Anomaly dev team develop official opencode provider for the vscode chat like Ollama already did.

zd-dalibor avatar Sep 07 '26 07:09 zd-dalibor

@thdxr You should compute your own routing ids by computing a (sparse) hash over the user prompts. Your current approach is lazy, because it puts all the burden on agent developers when you could have done it yourself.

99991 avatar Sep 07 '26 08:09 99991

you could use X-Interaction-Id from request header as session ID. @thdxr you lazy dumb axxhole. stxpid retxrded piece of thing!!! fix this IMMEDIATELY!!! I have paied for your stxpid service!!!

wjchen94 avatar Sep 07 '26 09:09 wjchen94

This is horrible. I am so stuck with it. Can you please fix it ASAP?

ankit-berlin avatar Sep 07 '26 09:09 ankit-berlin

Can't use my Opencode GO sub in VSCode because of this. Isn't VSCode one of the most common places outside opencode-cli to use the subscription? I wonder why they apply the change knowing they will break other platforms compatibility...

AntonioMrtz avatar Sep 07 '26 10:09 AntonioMrtz

@sandy081 could you please fix this ASAP?

zeerd avatar Sep 07 '26 10:09 zeerd

I love everything about this.

Opencode itself has had support for X-Session-Id https://github.com/anomalyco/opencode/issues/12930 and x-session-affinity https://github.com/anomalyco/opencode/pull/20744 added, then removed under unknown circumstances, then added again not even 3 weeks ago https://github.com/anomalyco/opencode/issues/42694 https://github.com/anomalyco/opencode/pull/43188

And now here we see a request to add custom headers with the tool name to an entirely different harness. x-opencode-session, really?

Since there's about as much chance of vscode adding a competitor's custom header like this as hell freezing over, you can just add the header as a static entry like this to your individual model config and continue using opencode in vscode:

"requestHeaders": { "x-opencode-session": "ARE YOU KIDDING ME DAX" }

Do note that this might be problematic when using the same model from two chats at once. But then you could just do the reasonable thing and cancel your subscription, which is what I'll be doing.

So long and thanks for all the fish.

wbsch avatar Sep 07 '26 16:09 wbsch

According to official VS Code docs in https://code.visualstudio.com/docs/agent-customization/language-models#_add-a-custom-endpoint-model you can temporarily add by yourself the requested header by OpenCode, just edit in chatLanguageModels.json > yourCustomEndpoint > models > modelYouWantToUse and add requestHeaders like the example below.

	{
		"name": "OpenCode Anthropic",
		"vendor": "customendpoint",
		"apiKey": "${input:chat.lm.secret.-####}",
		"apiType": "messages",
		"models": [
			{
				"id": "qwen3.7-plus",
				"name": "Qwen3.7 Plus",
				"url": "https://opencode.ai/zen/go/v1/messages",
				"toolCalling": true,
				"vision": true,
				"maxInputTokens": 1000000,
				"maxOutputTokens": 131072,
				"requestHeaders": {
					"x-opencode-session": "ses_b5s4af482as55"
				}
			}
		]
	}

tianrodez avatar Sep 07 '26 16:09 tianrodez

Infuriating! OpenCode’s API design is constantly changing and fails to adhere to standard, broadly applicable design principles, effectively shifting the burden of its own internal problems onto the entire ecosystem. For Copilot, requiring custom request headers for every third-party inference provider is simply not a sensible approach. OpenCode’s attitude comes across as excessively arrogant and discourteous.

so bad @thdxr

tomelpqueentree avatar Sep 08 '26 02:09 tomelpqueentree

Thanks @wbsch and @tianrodez for the requestHeaders workaround.

Integrated it for OpenCode Go models in: https://github.com/shibadogcap/opencode-copilot-chat This is a fork of https://github.com/Pikacnu/opencode-copilot-chat.

shibadogcap avatar Sep 08 '26 06:09 shibadogcap

shifting your own architectural needs to everyone else's problem is insane

megaabc1 avatar Sep 08 '26 08:09 megaabc1

If you can correctly identify UA GitHubCopilotChat/0.63.0, then you should be able to identify X-Interaction-Id just as easily. That’s the model provider’s responsibility!

crwin avatar Sep 08 '26 13:09 crwin

@vritant24 Could you take a look at this issue? Thank you!

tamuratak avatar Sep 08 '26 22:09 tamuratak

Tried the new GitHub Copilot desktop app yesterday. Ran into the same issue with OpenCode Go. Shame.

VariableVince avatar Sep 11 '26 12:09 VariableVince

There's already a community extension, OpenCode for Copilot Chat, that implements this feature. It automatically sends the x-opencode-session header on all inference requests to the OpenCode gateway, providing the stable per-conversation ID you need.

However, I think Anomaly should provide this as an official LLM provider extension for Copilot Chat rather than relying on community contributions. An official implementation would be more reliable for routing and optimization, and would reach significantly more users through official channels.

sh2 avatar Sep 13 '26 08:09 sh2