Skip to content

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

Closed as not planned

Description

@salvinoarmati

[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 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 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.

Activity

  1. buremba commented on Jul 15, 2025

    @buremba

    @salvinoarmati were you able to find a workaround? This is currently a blocker for my use-case

  2. dcalsky commented on Jul 23, 2025

    @dcalsky

    Although session ids are different between the first and second calls, claude can really continue to work with the previous context.

  3. iamgajendra commented on Jul 25, 2025

    @iamgajendra

    @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.

    User message 1 -> assistant response (sessionId: 1)
    User message 2 -r 1 -> assistant response (sessionId: 2)
    User message 3 -r 2 -> assistant response (sessionId: 3) 
    
    

    When you do -r sessionId claude-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.

  4. foertel commented on Jul 26, 2025

    @foertel

    CLI: claude --resume abc123 ✅ Works correctly

    That is one interesting sessoin id. 🙄 Do we have a filter against AI slop issues? I don't think, they are helping our cause.

    Compare the session IDs - they should match but don't

    Yes. They also don't in CLI. You hallucinated. :-/

  5. github-actions commented on Dec 4, 2025

    @github-actions

    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.

  6. github-actions commented on Jan 4, 2026

    @github-actions

    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.

  7. github-actions commented on Jan 13, 2026

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apiautocloseIssue will be closed automaticallybugSomething isn't workinghas reproHas detailed reproduction stepsmemoryplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions