Repository navigation
Description
[BUG] TypeScript SDK ignores resume parameter - session resumption not working
Bug Description
The resume parameter in the TypeScript SDK is completely ignored, breaking session resumption functionality. While the CLI version correctly supports --resume, the TypeScript SDK creates new sessions on every request regardless of the resume parameter.
Environment
- SDK Version: @anthropic-ai/claude-code@1.0.35
- Node.js Version: v23.10.0
- OS: macOS 15.5 (24F74)
- Architecture: ARM64 (Apple Silicon)
Steps to Reproduce
- Create a Claude session and capture the session ID from the first request
- Make a second request using
resume: sessionIdparameter - Compare the session IDs - they should match but don't
Expected Behavior
Session resumption should work as documented in the CLI:
- CLI:
claude --resume abc123✅ Works correctly - TypeScript:
query({resume: 'abc123'})❌ Broken
The TypeScript SDK should honor the resume parameter and continue the existing conversation.
Actual Behavior
- TypeScript SDK completely ignores the
resumeparameter - New session ID generated on every request
- Conversation context lost between requests
- No error or warning indicating the parameter is invalid
Minimal Reproduction
File: minimal-reproduction.js
const { query } = require('@anthropic-ai/claude-code');
const fs = require('fs');
const os = require('os');
const path = require('path');
async function testResumeParameter() {
console.log('🧪 Testing Claude SDK Resume Parameter Bug');
console.log('SDK Version: @anthropic-ai/claude-code@1.0.35\n');
// Create temp directory
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-resume-bug-'));
process.chdir(tempDir);
let firstSessionId = null;
try {
// STEP 1: First request to get initial session ID
console.log('📤 STEP 1: Making first request...');
for await (const message of query({
prompt: 'Create a file called test.txt with "Hello World"',
options: { cwd: tempDir, maxTurns: 2, permissionMode: 'acceptEdits' }
})) {
if (message.session_id && !firstSessionId) {
firstSessionId = message.session_id;
console.log(`✅ First session ID: ${firstSessionId}`);
}
if (message.type === 'result') break;
}
// STEP 2: Try to resume with the session ID
console.log('\n📤 STEP 2: Attempting to resume session...');
console.log(`🔗 Using resume parameter: ${firstSessionId}`);
let secondSessionId = null;
for await (const message of query({
prompt: 'Create another file called test2.txt with "Hello Again"',
resume: firstSessionId, // 🚨 THIS SHOULD WORK BUT DOESN'T
options: { cwd: tempDir, maxTurns: 2, permissionMode: 'acceptEdits' }
})) {
if (message.session_id && !secondSessionId) {
secondSessionId = message.session_id;
console.log(`📨 Second session ID: ${secondSessionId}`);
}
if (message.type === 'result') break;
}
// STEP 3: Check if resume worked
console.log('\n📊 RESULTS:');
console.log(` 🔗 First session: ${firstSessionId}`);
console.log(` 🔗 Second session: ${secondSessionId}`);
console.log(` 🔄 Sessions match: ${firstSessionId === secondSessionId ? '✅ YES' : '❌ NO'}`);
if (firstSessionId === secondSessionId) {
console.log('\n✅ SUCCESS: Resume parameter works!');
} else {
console.log('\n❌ BUG CONFIRMED: Resume parameter ignored!');
console.log(' TypeScript SDK is not honoring the resume parameter.');
}
} finally {
// Cleanup
process.chdir('..');
fs.rmSync(tempDir, { recursive: true, force: true });
}
}
// Run the test
testResumeParameter().catch(console.error);Output:
🧪 Testing Claude SDK Resume Parameter Bug
SDK Version: @anthropic-ai/claude-code@1.0.35
📤 STEP 1: Making first request...
✅ First session ID: 7fbe2a88-89de-4006-98d7-d8471819f61d
📤 STEP 2: Attempting to resume session...
🔗 Using resume parameter: 7fbe2a88-89de-4006-98d7-d8471819f61d
📨 Second session ID: 5ae866dc-30fc-4cc4-ae00-766e1aba2792
📊 RESULTS:
🔗 First session: 7fbe2a88-89de-4006-98d7-d8471819f61d
🔗 Second session: 5ae866dc-30fc-4cc4-ae00-766e1aba2792
🔄 Sessions match: ❌ NO
❌ BUG CONFIRMED: Resume parameter ignored!
TypeScript SDK is not honoring the resume parameter.
Additional Testing
I tested all possible parameter structures to ensure this isn't a parameter placement issue:
- ❌ Top-level:
query({resume: sessionId, ...}) - ❌ In options:
query({options: {resume: sessionId}}) - ❌ In executableArgs:
query({executableArgs: ['--resume', sessionId]})
All approaches failed - session IDs change on every request.
Impact
For Developers:
- Breaks multi-turn conversations in TypeScript applications
- Forces workarounds or prevents adoption of the TypeScript SDK
- No way to maintain conversation context programmatically
For Applications:
- Cannot build stateful AI assistants
- Lost conversation history between requests
- Increased token costs (no context reuse)
Documentation Issues
- CLI documentation shows working
--resumefunctionality - TypeScript SDK documentation doesn't mention
resumeparameter at all - No error/warning when invalid parameters are used
- Mismatch between CLI capabilities and TypeScript SDK
Comparison: CLI vs TypeScript
| Feature | CLI | TypeScript SDK | Status |
|---|---|---|---|
--resume sessionId |
✅ Works | ❌ Ignored | Broken |
--continue |
✅ Works | ❌ Not available | Missing |
| Session persistence | ✅ Works | ❌ Broken | Critical |
Expected Fix
The TypeScript SDK should:
- Honor the
resumeparameter when provided - Continue existing sessions instead of creating new ones
- Update documentation to reflect TypeScript capabilities
- Add parameter validation with helpful error messages
Workaround
Currently no workaround exists - session resumption is completely broken in the TypeScript SDK.
Related
This appears to be a fundamental issue with the TypeScript SDK implementation not properly bridging CLI parameters to the underlying Claude API calls.
Activity
buremba commentedon Jul 15, 2025
@salvinoarmati were you able to find a workaround? This is currently a blocker for my use-case
dcalsky commentedon Jul 23, 2025
Although session ids are different between the first and second calls, claude can really continue to work with the previous context.
iamgajendra commentedon Jul 25, 2025
@salvinoarmati @buremba I was stuck on the same issue for days.. finally found out the root cause.
This is not a bug in the sdk or the cli. Session is not suppose to be same between messages.
When you do
-r sessionIdclaude-code will resume the session and process your prompt but while responding it will create a new sessionId. Now if you want to resume the same session then pass the latest sessionId in resume parameter.foertel commentedon Jul 26, 2025
That is one interesting sessoin id. 🙄 Do we have a filter against AI slop issues? I don't think, they are helping our cause.
Yes. They also don't in CLI. You hallucinated. :-/
github-actions commentedon Dec 4, 2025
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
github-actions commentedon Jan 4, 2026
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
github-actions commentedon Jan 13, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.