diff --git a/CHANGELOG.md b/CHANGELOG.md index a39d79cf9..2ba299e8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Anthropic: request uncompressed SSE (`accept-encoding: identity` + `:decompress-body false`) so streamed responses arrive token-by-token instead of all at once. - Remote REST API now surfaces tool calls awaiting approval: `GET /api/v1/chats/:id` returns `pendingToolCalls` and session/list-chats entries include `pendingApprovalCount`. ## 0.136.2 diff --git a/src/eca/llm_providers/anthropic.clj b/src/eca/llm_providers/anthropic.clj index f6d065897..3757b90b1 100644 --- a/src/eca/llm_providers/anthropic.clj +++ b/src/eca/llm_providers/anthropic.clj @@ -97,7 +97,9 @@ (merge (assoc-some {"anthropic-version" "2023-06-01" - "Content-Type" "application/json"} + "Content-Type" "application/json" + ;; Keep SSE uncompressed so it streams token-by-token (see :decompress-body below). + "accept-encoding" "identity"} "x-api-key" (when-not oauth? api-key) "Authorization" (when oauth? (str "Bearer " api-key)) "anthropic-beta" (when oauth? "oauth-2025-04-20")) @@ -115,6 +117,7 @@ {:headers headers :body (json/generate-string body) :throw-exceptions? false + :decompress-body false :http-client (client/merge-with-global-http-client http-client) :as (if on-stream :stream :json)})] (if (not= 200 status)