[BUG] TypeScript SDK ignores `resume` parameter - session resumption not working

Resolved 💬 7 comments Opened Jul 1, 2025 by salvinoarmati Closed Jan 4, 2026

[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

  1. Create a Claude session and capture the session ID from the first request
  2. Make a second request using resume: sessionId parameter
  3. Compare the session IDs - they should match but don't

Expected Behavior

Session resumption should work as documented in the CLI:

  • CLI: claude --resume abc123Works 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 resume parameter
  • 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:

  1. Top-level: query({resume: sessionId, ...})
  2. In options: query({options: {resume: sessionId}})
  3. 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

  1. CLI documentation shows working --resume functionality
  2. TypeScript SDK documentation doesn't mention resume parameter at all
  3. No error/warning when invalid parameters are used
  4. 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:

  1. Honor the resume parameter when provided
  2. Continue existing sessions instead of creating new ones
  3. Update documentation to reflect TypeScript capabilities
  4. 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.

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗