SIGN IN SIGN UP

fix: preserve Deep Agents conversation context after stopping and resuming a session (#19919)

## Background

Deep Agents sessions resumed after session.stop() lost prior
conversation messages across host processes, while detach/reattach
retained them.

## Root Cause

The bridge stored LangGraph checkpoints only in a process-local
MemorySaver, and doStop() terminated that process without persisting its
state. The original reproduction confirmed this by returning UNKNOWN
after stop/resume while detach/reattach retained Felix.

## Summary

The bridge now atomically saves MemorySaver checkpoints before stopping,
restores them when spawning a resumed bridge, and removes stale state
for fresh or destroyed sessions. A patch changeset was added.

## Testing

Added tests covering checkpoint and pending-write restoration plus
resumed bridge startup, with all 79 Deep Agents tests passing.

## End-to-end Validation

- Immutable reproduction command passed: detach/reattach and stop/resume
both retained context across host processes.
- `FAIL_ON_ERROR=1 pnpm -C examples/ai-functions exec tsx
src/harness-agent/deepagents/resume.ts` was attempted but blocked before
session creation by Vercel Sandbox authentication HTTP 403.

## Related Issues

Fixes #19693

Closes #19918

---------

Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com>
Co-authored-by: Felix Arntz <3531426+felixarntz@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
9ec34bdecf86b59c8410c6c8af15cc5c2f7c07dd
Parent: 051a41d
Committed by GitHub <noreply@github.com> on 8/28/2026, 5:49:51 PM