@justmpm/qwen-chat-key
v1.1.0
Published
OpenCode plugin that injects x-opencode-chat-key header for per-session-agent browser context isolation in QwenProxy
Maintainers
Readme
@justmpm/qwen-chat-key
OpenCode plugin that injects a stable x-opencode-chat-key header into provider requests targeting QwenProxy.
Enables per-session / per-agent / per-model browser context isolation inside the proxy, so parallel agents never interfere with each other's Qwen chat state.
Installation
npm install -D @justmpm/qwen-chat-keyThen register in opencode.json:
{
"plugin": [
"@justmpm/qwen-chat-key"
]
}Restart OpenCode — plugins are loaded at startup only.
How it works
For every request to the qwen-local provider, the plugin computes a SHA-256 hash of:
v1|<sessionID>|<agent>|<providerID>|<modelID>And sends it as:
| Header | Value |
|---|---|
| x-opencode-chat-key | sha256(v1\|session\|agent\|provider\|model) |
| x-opencode-session-id | OpenCode session ID |
| x-opencode-agent | Agent name (e.g. nexus, worker) |
| x-opencode-provider-id | Always qwen-local |
| x-opencode-model-id | Model ID (e.g. qwen3.6-plus) |
QwenProxy uses the chat key to assign a dedicated Playwright BrowserContext (separate cookies, localStorage, page, and lock) to each unique combination. This guarantees:
- Same session + same agent + same model → same browser context → same Qwen chat
- Different agent → different browser context
- Different session → different browser context
- No header → fresh chat per request (fallback)
Requirements
- OpenCode with the
qwen-localprovider configured. - QwenProxy running locally.
License
MIT
