ECA chat does not work with Opencode Go
I got this error when I type something to the chat.
LLM response status: 400 body: {"type":"error","error":{"type":"MissingSessionID","message":"Error from provider (Console Go): Request is missing x-opencode-session and cannot be routed efficiently. Please see https://opencode.ai/docs/go/#where-can-i-use-it"}}
I used to work before until recently. It seems Opencode has added a header validation. https://opencode.ai/docs/go/#where-can-i-use-it
@suzuki11109 you can add custom headers with extraHeaders config, maybe try that?
ref
@ericdallo thanks for the pointer, but I think this is not enough. If I get this correctly, OpenCode's docs (https://opencode.ai/docs/go/#where-can-i-use-it) ask non-OpenCode clients to:
- identify themselves with their own User-Agent rather than a generic HTTP-library name;
- send a stable session ID in x-opencode-session for each conversation (the same for every request in that conversation), which they use for routing and prompt caching.
extraHeaders covers the first point ("User-Agent": "eca"), but not the second. If I understood this correctly (disclosure: I used Claude Code to dig into this), with extraHeaders the value is fixed per provider or model (not per conversation) and is resolved once when the config loads, even with ${cmd:uuidgen}. So every chat would share one ID, which breaks the per-conversation routing and caching the header is meant for. I guess the change would be in the server rather than in eca-emacs, so it might make sense to move this issue to editor-code-assistant/eca. I can open a new one there if this is actually the case.
@suzuki11109 I moved the issue to eca. Yeah, I don't see how to solve this in a non opencode sepcific way, we shouldn't hardcode anything for specific providers just because they need headers with custom logic, ECA already expose extraHeaders to be generic and allow use other providers, this is the first provider I see that needs custom headers that keep changing, so not sure what to do here. c/c @zikajk
I guess we would need to have something like${session-cmd:uuidgen} and ${chat-cmd:uuidgen}? That sounds crazy...