Follow Discord
Sweep 03 Dec 2026 · 19:13Z Build v2.1.336 553 read Stable v2.1.332 Latest v2.1.336 Next v2.1.336 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

message-threads changedbuild-with-claude/message-threads

Nearest release: v2.1.333, published 4 hours after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+14added
Lines−4removed
From line 645 where the diff opens
First seen 2 Nov 2026 this site's first read of the page
Recorded edits12to this page, all time

The whole hunk

from line 645, old and new numbered
/
lines
from line 645
645645* A fallback model wrote the previous response. See [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks).
646646* The previous response is still generating.
647647* The request comes from a different organization or workspace.
648* The request comes from a different user or service account from the one that created the thread. A thread created with a [workspace key (legacy)](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) stays with that key, so use the same key for the whole thread.
648* The request comes from a different user or service account from the one that created the thread. A thread created with a [workspace key (legacy)](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) stays with that key, so use the same key for the whole thread.
649649* The new messages add something that the stored conversation can’t take. For example, the first image in a conversation that had none can return this error.
650* The previous response contains a `compaction` block, or the new messages contain one that has a summary. See [Message threads in Compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#message-threads).
650651 
651652To recover, follow these steps:
652653 
from line 669
668669 
669670When a response has `stop_reason: "refusal"`, do not continue the thread. The API might already hold the refused turn, and a continue request can’t remove it. Start a new thread with a create request that leaves out or rephrases the turn that led to the refusal. See [Refusals and fallback](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback). The SDK thread helper does this for you: it doesn’t keep the refused turn, and its next turn starts a new thread.
670671 
672If the response contains a `compaction` block, the summary was refused and the API stored nothing, so this section doesn’t apply. See [When a thread gets no summary](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#when-a-thread-gets-no-summary).
673 
671674### Use fallbacks with a thread
672675 
673676[Server-side fallback](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#server-side-fallback) is available with threads on the Claude API. Decide when you create the thread: send `fallbacks` on every request of the thread or on none. The value of `fallbacks` can change between requests. A continue request that adds or drops `fallbacks` returns a 400 error with the code `thread_fingerprint_mismatch`.
from line 692
689692 
690693## Compact a conversation
691694 
692A thread is append-only, so you can’t replace its earlier turns with a summary. To compact a conversation, start a new thread from the summary. Write the summary in your code and send it as an ordinary message in a new create request with `system` and `tools`. [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) is not available with threads (see [Features that threads don’t support](https://platform.claude.com/docs/en/build-with-claude/message-threads#unsupported)).
695A thread is append-only, so you can’t replace its earlier turns with a summary. To compact a conversation, start a new thread from the summary. You can write the summary in your code, or the API can write it when the conversation reaches a token threshold:
693696 
697* **Write your own summary.** Write the summary in your code and send it as an ordinary message in a new create request with `system` and `tools`. This approach needs no extra beta header. It works on every model and platform that supports threads.
698* **Use compaction at a token threshold.** On the Claude API, Claude Platform on AWS, and Claude in Microsoft Foundry, a thread accepts one form of the `compact_20260112` edit. For the steps and the limits, see [Message threads in Compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#message-threads).
699 
700[Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) is not available with threads (see [Features that threads don’t support](https://platform.claude.com/docs/en/build-with-claude/message-threads#unsupported)).
701 
694702## How the SDK helper behaves
695703 
696704What the helper does for you:
from line 715
707715 
708716* **Fallbacks.** While the API keeps answering from a fallback model, the helper sends the full conversation in a new create request on every turn because the API stores none of those turns. The helper goes back to continue requests after a response from the model that you requested. To move the conversation to the fallback model instead, start a new thread from the params with that `model` and without `fallbacks` as in [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks).
709717* **Dropped streams.** If a stream ends partway through a response, the helper keeps the finished blocks and any text that arrived, and the next turn sends the full conversation in a new create request. The helper doesn’t retry by itself: to re-send the interrupted turn instead, call `send()` (go, csharp: `Send()`; ruby: `send_message()`) with no messages. If the kept part ends in tool calls, answer them in your next message. If you stop reading a stream after it shows `stop_reason: "refusal"`, the helper treats that turn as a refusal.
718* **Compaction at a token threshold.** After a response with `stop_reason: "compaction"`, the helper’s next turn gets a 404 error. It then replays the full conversation, including the block, in a new create request, or stops using `thread` (see **Other errors**). A replay has messages before the block, so the API might not store it. If it doesn’t, the helper replays on every turn or stops using `thread`. To send only the summary, start a new thread from the params, with `messages` set to an `assistant` message that contains only the block. First, check that the block’s `content` is not `null`. If `stop_reason` is `"refusal"`, the helper takes back the messages that you gave to that call, so include them in your next request. See [Message threads in Compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#message-threads).
710719* **Other errors.** `thread_fingerprint_mismatch` and `thread_unsupported_request` errors reach your code. To carry on without `thread` after a `thread_unsupported_request` error, create the helper with `unsupported_request_behavior` (typescript, java, php: `unsupportedRequestBehavior`; go, csharp: `UnsupportedRequestBehavior`) set to `continue_unthreaded` (ruby: `:continue_unthreaded`; java: `CONTINUE_UNTHREADED`; csharp: `ContinueUnthreaded`; go: `BetaMessageThreadUnsupportedRequestBehaviorContinueUnthreaded`). With that setting, the helper also stops using `thread` when the first continue request after a replay returns `thread_not_found` again. The API might be unable to store that conversation. Without that setting, the helper replays on every turn. A tool runner that creates its own thread uses that setting by default.
711720 
712721The SDK’s beta tool runner also uses a thread by default. You can turn off this default when you create the runner.
from line 800
791800 
792801* [Message Batches](https://platform.claude.com/docs/en/build-with-claude/batch-processing). A request item that includes `thread` ends with an `invalid_request_error` in the batch results.
793802* [Token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting). A token counting request that includes `thread` returns a 400 error. Count the full conversation instead, with `system` and `tools`.
794* [Compaction](https://platform.claude.com/docs/en/build-with-claude/compaction). [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) is not available with threads. A request that includes `thread` returns a 400 error if it sets the `compaction` parameter or if it sends a `compaction` block with the `compact-2026-09-04` beta header. See [Compact a conversation](https://platform.claude.com/docs/en/build-with-claude/message-threads#compaction).
795* [Context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) except `clear_thinking_20251015` with `keep: "all"`.
803* [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand). A request that includes `thread` returns a 400 error if it sets the `compaction` parameter or sends a `compaction` block with a `signature`. Only compaction on demand adds a `signature`. You can still send that feature’s `compact-2026-09-04` beta header on a thread. See [Compact a conversation](https://platform.claude.com/docs/en/build-with-claude/message-threads#compaction).
804* [Compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold), except one form: the `compact_20260112` edit with `pause_after_compaction` set to `true` (the default is `false`) and no `instructions`. That form is available on the Claude API, Claude Platform on AWS, and Claude in Microsoft Foundry. Any other form returns a 400 error. See [Message threads in Compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#message-threads).
805* [Context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) except `clear_thinking_20251015` with `keep: "all"`. A request that includes `thread` returns a 400 error if it uses `clear_tool_uses_20250919`, or `clear_thinking_20251015` with another `keep` value or without `keep`.
796806* Organizations that have [HIPAA readiness](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#hipaa-readiness) enabled.
797807* Organizations that have [Inference hooks](https://platform.claude.com/docs/en/manage-claude/inference-hooks) turned on.
798808 
Feedback