From: Jakub Czajka Date: Tue, 11 Aug 2026 14:53:10 +0000 (+0000) Subject: [proxy] Refine claude-proxy: drop duplicate timestamps, simplify, add detail. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=guix.git [proxy] Refine claude-proxy: drop duplicate timestamps, simplify, add detail. Remove the (ts) helper from log — Shepherd's #:log-file already timestamps each line. Auto-append ~% in log so callers do not need to remember. Simplify classifier? with or+and=> for the vector->list fallback. Add classifier and thinking-disabled status to the request log line, and include the request path in error logs. Co-Authored-By: Claude --- diff --git a/conf/common/claude-proxy.scm b/conf/common/claude-proxy.scm index 5aeb52f..f2346db 100644 --- a/conf/common/claude-proxy.scm +++ b/conf/common/claude-proxy.scm @@ -51,23 +51,15 @@ (string->uri (or (getenv "CLAUDE_PROXY_UPSTREAM") "https://api.deepseek.com/anthropic"))) - (define (ts) - (strftime "%Y-%m-%dT%H:%M:%S%z" - (localtime (current-time)))) - (define (log fmt . args) (apply format (current-error-port) - (string-append "[claude-proxy] " - (ts) " " fmt) args) + (string-append "[claude-proxy] " fmt "~%") args) (force-output (current-error-port))) (define (classifier? json) - (define sys - (assoc-ref json "system")) (define blocks - (if sys - (vector->list sys) + (or (and=> (assoc-ref json "system") vector->list) '())) (define (has? prefix) (any (lambda (b) @@ -112,9 +104,10 @@ (hdrs (list (list 'content-type 'application/json) (cons 'x-api-key auth)))) - (log "~a ~a [~a]" + (log "~a ~a [~a~a]" 'POST path - (if is? "classifier" "pass")) + (if is? "classifier" "pass") + (if is? ", thinking-disabled" "")) (receive (rsp body-port) (http-request url #:method 'POST @@ -130,16 +123,18 @@ (list (cons 'content-type ct)) '()))) - (log " -> ~d~%" code) + (log " -> ~d" code) (values (build-response #:code code #:headers rhdrs) body-port))))) (lambda (k . a) - (log "error: ~a~%" k) + (log "~a ~a error: ~a" + 'POST + (uri-path (request-uri req)) k) (ok 502 "{\"error\":\"upstream unavailable\"}")))) (_ (ok 405 "{\"error\":\"method not allowed\"}")))) - (log "listening on 127.0.0.1:~d~%" port) + (log "listening on 127.0.0.1:~d" port) (run-server handler 'http `(#:port ,port