Files
magpie/docs
yetone 682e4253bf gateway: a Gemini call's thought signature is kept on disk and its id carries a 16-character key, not the signature — ids were 3KB+ and broke a client's PostgreSQL index (#2411, liangxyz)
Since #687 a tool call Gemini signed went to the client with the signature
inside its id (<id>__ts<n>__<base64url>), so the client's next request
brought it back. A Gemini 3 signature is often 2–6KB, so ids were too: LobeHub
stores tool_call_id in a btree index, whose rows are capped near 2.7KB, and
the write failed.

The signature is now written to <settings>/gemini-signatures/<key>, the key
being 12 bytes of its SHA-256 in base64url, and the id carries
__tsk16__<key> (≈36 characters). Coming back, the file is read and its hash
checked against the key; a file gone or changed is no signature, and the
call goes to Gemini with skip_thought_signature_validator, as an id a client
shortened already did. A file is touched when it is read or written again
and pruned 90 days after its last use (at most once an hour, on a write);
temp files from a write cut short go after an hour. When the folder can't
be written, the signature still rides in the id as before. Ids made before
this (__ts<n>__, __tsr<n>__, __ts__) are still read.

Real use: a sandbox HOME magpie serve with the owner's Antigravity account
copied in, antigravity/gemini-3.8-flash-high, a two-turn tool call over Chat
and over /v1/messages: ids came back as call_659137__tsk16__cOTtfB5LubcVSNaX
(36 characters), turn 2 answered from the tool result, and the store file
(584 bytes) was born on turn 1 and touched on turn 2's read.
gemini/gemini-3-flash-preview answered 502 (Gemini CLI no longer
supported), unrelated. Not tried in LobeHub itself; asked on the issue.

Tests: TestFortyCharacterIDThroughGateway now keeps the real signature
through a 40-character id; TestLongSignatureGivesShortID (6.4KB signature,
id ≤ 64, round trip); TestKeptSignatureGoneOrChanged; TestUnkeptSignature-
RidesInTheID; TestOldSignaturesPruned. Broken by hand: keepSignature
disabled fails FortyCharacter and LongSignature; the hash check removed
fails KeptSignatureGoneOrChanged.

Ran: gofmt; go vet -tags nogui ./internal/gateway/ for darwin, linux,
windows; targeted tests -count=3.
Full suite: go test -tags nogui -count=1 ./internal/gateway/ ok (466.9s);
the rest of the suite ran green on the batch this is rebased onto
(386d341e7).
2026-10-16 00:16:43 +08:00
..