New Features
ConversationResetMessagefor conversation reset events: The SDK now surfaces the CLI'sconversation_resetframe as aConversationResetMessagedataclass, letting applications detect when a/clearor other transcript-discarding flow resets the conversation mid-session. Includesnew_conversation_id,uuid, andsession_idfields. This widens theMessageunion — code that exhaustively matches withassert_neverwill need updating (#1196)- Message origin on
UserMessageandResultMessage: Neworigin: MessageOrigin | Nonefield onUserMessageandResultMessagesurfaces why a turn was initiated — distinguishing application-submitted prompts ("human") from background-task notifications, scheduled triggers, peer messages, and other session-injected turns. New exported types:MessageOrigin,MessageOriginKind,TaskNotificationOriginSubkind(#1199) resume_session_at/resume_drops_turnoptions for truncating resume:ClaudeAgentOptionsnow supportsresume_session_at(fork a session at an earlier transcript entry) andresume_drops_turn(validate that only entries from a specific turn are discarded). Enables safe rewind-to-before-last-prompt without silently dropping unobserved messages (#1198)
Bug Fixes
- Seed
settings.jsoninto temp config dir onSessionStoreresume: Resuming from aSessionStorenow copiessettings.jsonandcowork_settings.jsoninto the temporary config directory, preservingapiKeyHelperauth, user hooks, env vars, and permissions. Previously, hosts authenticating solely viaapiKeyHelperwould fail with "Not logged in" on resume (#1197) - Improved error messages for failed resume: When the CLI rejects a resume (e.g. nonexistent session or
resume_drops_turnguard failure), pending control requests likeinitialize()now receive the actual error text instead of a generic "Command failed with exit code 1" (#1198)
Internal/Other Changes
- Updated bundled Claude CLI to version 2.1.229
PyPI: https://pypi.org/project/claude-agent-sdk/0.2.137/
pip install claude-agent-sdk==0.2.137