]> git.ekhem.eu.org Git - guix.git/commit
[proxy] Stream responses and bound waits with an idle timeout. main
authorJakub Czajka <jakub@ekhem.eu.org>
Thu, 3 Sep 2026 22:54:31 +0000 (22:54 +0000)
committerJakub Czajka <jakub@ekhem.eu.org>
Thu, 3 Sep 2026 22:54:31 +0000 (22:54 +0000)
commitbe52bbed442f1e420b8d1d844b22130733362f05
tree0b8b0b0535a922ed11534e5874da9334b173a8f0
parent34e28b1f9e15a9f3f3121b98b1dd841f830fab99
[proxy] Stream responses and bound waits with an idle timeout.

Rewrite the proxy to relay upstream responses incrementally:
each chunked SSE frame reaches the client as it arrives instead
of being buffered, and every network wait — connect, response
headers, and gaps mid-stream — is bounded by an idle timeout
(CLAUDE_PROXY_TIMEOUT, default 60 s).  A mid-stream expiry emits
a typed SSE error and aborts the relay.

DeepSeek reasoning models default to thinking on, which stalls
non-streaming requests, so such requests now get thinking:disabled
injected unless they set a thinking field themselves; streaming
and explicit-thinking requests pass through untouched.  This
replaces the old safety-classifier sniffing.

Log one line per event with a per-request id, so a single request
can be traced with grep 'req=<id>'.  Handle portless https
upstreams (scheme-default port and Host header) and give the
Shepherd service a SIGTERM stop with a paced respawn that
survives the port overlap during guix home reconfigure.

Rework the tests around a deterministic fake upstream that can
stream with gaps and stall: assert incremental relaying,
thinking injection, 504 on stalled headers, the mid-stream typed
error, log traceability, and error passthrough.  Add a TLS twin
pair — an HTTPS fake on 127.0.0.1:443 behind a self-signed test
certificate and a proxy on portless https://127.0.0.1 — to guard
scheme-default-port and TLS record handling.  vps-base.scm now
builds its test services from claude-proxy-test-os-services
instead of duplicating the wrapper.

Co-Authored-By: Claude <noreply@anthropic.com>
conf/common/claude-proxy.scm
tests/claude-proxy-test-cert.pem [new file with mode: 0644]
tests/claude-proxy-test-key.pem [new file with mode: 0644]
tests/claude-proxy.scm
tests/vps-base.scm