[FEATURE] Agent SDK: Add option to skip historical messages when resuming sessions with streaming
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When resuming a session with include_partial_messages=True, the SDK streams all messages from the beginning of the conversation history, including messages from previous rounds. For sessions with long conversation histories (e.g., 100+ turns), this causes:
- Unnecessary network overhead and latency
- Redundant output of historical messages that the user has already seen
- Poor UX when the user only wants to see new messages and intermediate steps from the current query
Currently, there's no way to skip the historical message stream while still getting real-time streaming of new messages.
Proposed Solution
Add an optional parameter to ClaudeAgentOptions (e.g., skip_historical_messages=True) that, when set during resume, instructs the SDK to:
- Use the full conversation history for Claude's reasoning and context (server-side)
- Only stream NEW messages generated after the resume call to the client
- Allow users to manage message history themselves (decide what to display, cache, or discard)
This gives users full control over which messages to output, store, or process, rather than forcing the SDK to stream all historical messages.
Alternative Solutions
_No response_
Priority
Critical - Blocking my work
Feature Category
Developer tools/SDK
Use Case Example
A custom chat interface where the user manages their own message history and UI:
- User has a 50-turn conversation stored in their own database/cache
- User resumes the session and only wants to see new messages in real-time
- Currently: SDK streams all 50 previous messages + new ones, forcing the user to filter
- With the proposed feature: Only new messages stream to the client, user's app displays
only what it chooses from its own history management
This is important for:
- Custom UI/chat interfaces with their own message storage
- Applications that need fine-grained control over message lifecycle
- Reducing bandwidth and latency in production deployments
- Decoupling message display logic from SDK streaming behavior
Additional Context
_No response_