Repository navigation
fix(sdk-ts): forward resumeSessionId to Claude Code as resume - #1216
reachtrevor wants to merge 3 commits into
Conversation
HarnessOptions accepts resumeSessionId, but ClaudeCodeProvider never passed it to the Claude Agent SDK, so every harness call with provider 'claude-code' started a fresh session. Map a non-empty resumeSessionId to the SDK's resume option, matching the Python provider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Trevor Pierce <trevor@reachtrevor.com>
|
|
|
Hi @reachtrevor, Thanks for wiring
I’m pushing one follow-up commit with both fixes and their regression tests, plus a merge commit to bring the branch up to date with I verified with the official Claude Agent SDK against a local test endpoint that a follow-up reused the same session and included the prior turn. The full TypeScript suite finished with 1,500 tests passed and 1 skipped. |
@reachtrevor please also sign the CLA here when you have a minute. Thanks :) |
Performance
✓ No regressions detected |
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
|
Closing this for now because the CLA is still unsigned for reachtrevor's commit (the bot asked on Nov 18, and again on Nov 20). The change itself was approved, so once it's signed through the CLA link above, leave a comment and we'll reopen and merge it. |
Summary
HarnessOptions.resumeSessionIdis part of the TypeScript harness API, and the runner passes it through to the provider, butClaudeCodeProvidernever forwards it to the Claude Agent SDK. As a result,agent.harness(prompt, { provider: 'claude-code', resumeSessionId })silently starts a new Claude Code session on every call. The Python provider already handles this (sdk/python/agentfield/harness/providers/claude.pymapsresume_session_idtoagent_options["resume"]), and the TSpiprovider already honorsresumeSessionId.This PR maps a non-empty string
resumeSessionIdto the SDK'sresumeoption inClaudeCodeProvider.execute. An absent or empty value leavesresumeunset, so existing callers are unaffected.Type of change
Test plan
cd sdk/typescript && npx vitest run --config vitest.config.ts tests/harness_provider_claude.test.ts(16 passed)cd sdk/typescript && npm test(102 files, 1494 passed, 1 skipped)cd sdk/typescript && npm run lint(tsc --noEmit, clean)Test coverage
Added a parameterized test in
sdk/typescript/tests/harness_provider_claude.test.ts, mocking@anthropic-ai/claude-agent-sdkthe same way as the existing provider tests. It asserts thatresumereachesquery()options whenresumeSessionIdis set, and thatresumeis absent whenresumeSessionIdis missing or an empty string. The new test fails without the provider change.coverage-baseline.jsonin this PR only if the removal caused a legitimate regression and I called it out in the summary above.Checklist
Related issues / PRs
None found.