Files
magpie/docs
deephbz d9e87eb328 gateway: clients opt into Claude subscription cache marks and TTLs (#1717)
Problem:
Messages clients need control of cache boundaries and TTLs when a Claude
subscription answers. Ordinary clients must retain their run identity,
prompt and environment. A routing group's API-key member keeps its marks
and must not report the subscription bridge's drops.

Change:
Select client-owned marks only with X-Magpie-Cache-Marks: client. Map system
and fresh-history boundaries and the request tail, default missing TTLs to
5m, validate slot and TTL order, and separate opted-in run identities.
Retain prefix constraints across live and saved runs. Report unmappable
marks only for the Claude subscription try. Bound its selection hold to
two seconds and clear the report and hold for a non-Claude fallback.
Check ordinary identity bytes without a version-specific hash golden.

What was run:
Sandbox HOME, nogui: go vet ./... on darwin; gateway vet with GOOS=linux
and GOOS=windows; full gateway tests; focused cache and usage tests with
-race. gofmt and git diff --check passed. The group probe failed before
the fix with tools:1 on the API-key reply in both routing orders and both
stream modes. Hand-broken candidate scoping, stale report clearing,
keepalive holds and ordinary identity bytes each failed behavior tests.
Live, Claude Code on a Claude subscription and an Anthropic API key,
through a recording proxy: in a group whose API-key member answers, in
either order and both stream modes, the reply has no dropped-mark header
and upstream receives the tool mark; a Claude answer reports tools:1; a
failed Claude try followed by an API-key answer leaves no report. With a
delayed API-key reply, the group's first keepalive came 0.85 s after a
direct request's. Without the header, the outgoing request equals one
from a gateway built at the same base. No GUI or real Linux/Windows
execution.
2026-10-16 14:16:51 +08:00
..