[FEATURE] Core: `providerData` on `TextBlock` for session restore and model switches
Human Overview
Server-side compaction returns a signed summary that only the producing provider can read. Strands stores it as an ordinary summary TextBlock with a new provider-agnostic providerData field. The block survives session restores and becomes plain text on a model switch. Anthropic (#5401) and OpenAI Responses (#5409) both build on this.
SDK Language
Both / Not language-specific
Problem Statement
A native compaction result is only valid on the provider that produced it, and its signature has to be sent back unchanged. Strands has nowhere to keep that data on a message. A restored session would lose it, and another provider would get a block it can't accept. Context strategies could also edit it and break the signature.
Proposed Solution
Part 1 of design 0022. This replaces the earlier dedicated compaction content block.
- Add an optional
providerData: ProviderData { provider, data }field toTextBlock. Example (Anthropic):{"provider":"anthropic","data":{"type":"compaction","signature":…,"encrypted_content":…}}. The change is additive and backwards compatible. - Rules:
- Only the producing provider reads
providerData. For example,AnthropicModelsends{ ...data, content: text }. Every other provider sendstextas plain text. - Strategies never edit it.
_blockMatchesTargetskips anyTextBlockwithproviderData. toJSON/fromJSON/contentBlockFromDatakeep it.textis the only copy of the summary.
- Only the producing provider reads
- Test save and restore with the file, S3, and repository session managers.
Done when:
- Round-trip unit tests pass in Python and TypeScript.
- Session restore integ tests pass with the file, S3, and repository session managers.
- A switch from
AnthropicModeltoBedrockModelsends plain text. Tests record the expected result: a 400 underprefix_mismatch_behavior: "error", and success underdrop_block.
Use Case
An agent that compacted on AnthropicModel resumes from a saved session, or falls back to BedrockModel, and keeps working.
Additional Context
- Parent epic: #5410
- Blocks: #5401, #5409
- Sibling core work: #5464 (
Model.compact(),compactionSplitIndex, ContextManager routing) - Design:
team/designs/0022-server-side-compaction-support.md(#5242) - Related: #4270, #4769.
Reopening: design 0022 now stores compactions as a summary TextBlock with providerData instead of a dedicated compaction block. Scope rewritten to match.