Skip to content

feat: add clear() and resume() for warm subprocess reuse without MCP re-handshake#1051

Open
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1035-clear-runtime-resume
Open

feat: add clear() and resume() for warm subprocess reuse without MCP re-handshake#1051
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1035-clear-runtime-resume

Conversation

@ashishpatel26

Copy link
Copy Markdown

Summary

  • Adds clear() to ClaudeSDKClient: resets session without subprocess restart
  • Adds resume(session_id): switch to named session on the warm process
  • Avoids 60s MCP handshake penalty on every new conversation

Changes Made

  • clear() and resume() methods in ClaudeSDKClient
  • _session_id field tracks current session
  • query() uses stored session ID when no explicit session_id passed

Testing

  • Unit tests added (tests/test_clear_resume.py)
  • All existing tests pass

Related Issue

Closes #1035

… reuse

- clear() resets session_id without restarting the subprocess
- resume(session_id) switches to a named session on the warm process
- Avoids 60s MCP re-handshake cost on each new conversation
- query() session_id param now defaults to the stored _session_id

Resolves anthropics#1035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: clear() and runtime resume for warm subprocess reuse

1 participant