Commit Graph
1 Commits
Author SHA1 Message Date
yetone 2979fbdc99 gateway: OpenCode 1's promptCacheKey reaches the upstream as prompt_cache_key (#5468)
OpenCode 1 (opencode-ai 1.19.5) with its provider's setCacheKey writes the
session's key into a Chat body as camelCase promptCacheKey (a real run on
mote against a recording server: "promptCacheKey":"ses_…"), a field no Chat
API reads; a passthrough upstream got it as written and no cache key, a
translated route never read it. The next commit has magpie set setCacheKey
for OpenCode, so this comes first.

Now a Chat request's promptCacheKey is taken out and sent as
prompt_cache_key, for every route (handle, beside thinkingEffort), so
req.CacheKey and the relay both see it. A prompt_cache_key the body has
already is the one kept. The body is re-encoded without HTML escaping.

Run on mote: go test -run 'OpenCode|CacheKey' ./internal/gateway ok; go vet
./internal/gateway on darwin, GOOS=linux and GOOS=windows; go build ./...
(darwin, windows).
Broken by hand: without the cacheKeyCamel call, TestOpenCodeCamelCacheKey
fails (upstream body still "promptCacheKey":"ses_1a2b", no
prompt_cache_key).
Not tried: OpenCode 1 through a running magpie gateway end to end (the
recording server saw OpenCode's body; the test covers magpie's half).

Reported-by: mariamatrix
Reported-by: mahiro233
2026-11-06 15:02:53 +08:00