mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-16 17:09:09 +00:00
## Summary - The Command Code `/alpha/generate` CLI fallback (taken on 403/404 from `/provider/v1/*`, e.g. Go plans or CLI-only models) sent a random `x-session-id` on every request and no envelope `threadId`. Upstream keys its prompt cache on that session, so every turn rebuilt the whole prefix. - Now one v4-shaped id is derived per conversation and sent as both `x-session-id` and the envelope `threadId`. - Hashed ids are salted per tenant (connection id, else API key), so two connections with the same opening never present the same upstream session. ## Attribution Thanks to [@vinhhap](https://github.com/vinhhap) for the original implementation. ## Changes - `open-sse/executors/commandCode/sessionId.ts` (new): `commandCodeSessionId()` resolves the session in this order: 1. explicit client session: `prompt_cache_key`, then the shared header/body session fields from `resolveOpencodeSessionIdentity` (`x-session-id`, `x-claude-code-session-id`, `session_id`, `thread_id`, `conversation_id`, Claude Code `metadata.user_id` JSON, …). A UUID is reused as-is (lower-cased); any other value is hashed with sha256 into a v4 UUID. 2. otherwise sha256 of the CLI params' system text plus the first user turn, which stays the same while later turns are appended. 3. a random UUID only when there is nothing to key on (the previous behavior). The raw client session and the tenant key only go into the hash. - `open-sse/executors/commandCode.ts`: `executeCliFallback` builds the envelop
6.3 KiB
6.3 KiB