sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

Epic: server-side context management for preserved-thinking models

Open jimbrub opened this issue 1 month ago • 2 comments

Summary

Preserved-thinking Claude models (Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1) bind each thinking block to the system prompt, tools, and history that came before it. Strands' context manager edits that history on the client, so the next request fails with a 400, or the #5171 drop_block retry throws the reasoning away. Each technique that edits history needs a server-side or append-only form.

Design: team/designs/0022-server-side-compaction-support.md (#5242). Part of #5160.

Part 1: summarization

  • [x] #5242 Review design 0022 with the team
  • [x] #5464 Core: overridable Model.compact(), compactionSplitIndex, ContextManager routing
  • [x] #5402 Core: providerData on TextBlock, session restore and model switch
  • [x] #5401 Anthropic native compaction (blocked by #5464, #5402)
  • [x] #5404 Compaction token usage and spans (blocked by #5464, #5401) Moved to #6018.
  • [ ] #5465 Spike: native compaction on other providers (Bedrock, Vertex, Foundry, gateways) Moved to #6018.
  • [x] #5405 Docs: serverCompaction, provider matrix, Offload.summarize behavior change (blocked by #5401, #5402, #5465)
  • [x] #5466 Follow-up: gate on model metadata capabilities (blocked by #5305, #5401, #5465)

Each item ships with Python and TypeScript parity, unit tests for every new branch, and integ tests on preserved-thinking models, including a comparison of native and client-side summaries.

Part 2: other history edits

  • [x] #5176 Mid-conversation system messages
  • [ ] #5407 Tool list changes as mid-conversation system messages (blocked by #5406, #5176) Moved to #6018.

Clearing tool results (#5406) and old thinking (#5408) server-side moved to #6018.

Part 3: other providers

Moved to #6018: #5409 OpenAI Responses server-side compaction.

jimbrub avatar Oct 22 '26 14:10 jimbrub

Status update on Part 1 after #5470. There are no changes to the checklist above; this comment adds new tickets and one reorder.

#5464 (#5470). It shipped as an experimental Model.summarize(), not compact(). Treat it as a placeholder: the final API shape is tracked in #5733. The as-built differences are noted on #5464. One of them is a behavior change for base models: message 0 is kept, and some low-preserve_recent passes are skipped.

Reorder: #5466 before #5401. Model.model_info capabilities landed in #5313, so #5466 doesn't need to wait for #5305. Gating on a capability before the first summarize() override lands avoids the override-detection problems found in #5470's review. Details on #5466.

New tickets (added as sub-issues):

  • #5733: separate native compaction from base summarization, and replace the placeholder Model.summarize(). A summary is stored as a TextBlock with metadata.offloaded, plus providerData from #5402 for native results.
  • #5734: evaluate base summarization strategies across models (keep message 0 or not, request shape, summarizer model, prompt, placement), including downstream task success over repeated passes. This also covers Part 1's "comparison of native and client-side summaries".
  • #5735: refine the base summarizer system prompt, chosen from the evaluation's results (blocked by #5734).
  • #5736: summarize after message 0 when the cut lands on the last message. This closes the skipped-pass gap #5470 introduced for preserve_recent ≤ 1.

Order for Part 1 from here:

  1. #5402 and #5466, in parallel.
  2. #5401, then #5404.
  3. #5734, then #5735.
  4. #5733, informed by the evaluation and by #5401's override.
  5. #5736 at any point.

jimbrub avatar Nov 02 '26 16:11 jimbrub

Server-side summarization ships for preserved-thinking Claude models via #5840, #5924, #5962, #6022 and docs in #6026. Remaining follow-ups (#5465, #5407, #5735) moved to #6018.

jimbrub avatar Nov 12 '26 16:11 jimbrub