Sandbox takeover: the saved transcript loses everything the first host delivered before the restart
Maintainer thường phản hồi trong vòng 1 ngày
@tombeckenham đang làm issue này rồi.
Từ ngày 5/11/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
TanStack AI version
@tanstack/ai-sandbox 1.1.0 and main (644a780b0). @tanstack/ai 1.1.0 and main. @tanstack/ai-persistence 1.0.1. @tanstack/ai-claude-code 1.0.1.
Framework/Library version
Server only. chat() driven by sandboxRunDriver in a Node 24 route handler. No client framework is involved.
Describe the bug and the steps to reproduce it
A host restarted during a 40-second Bash call. sandboxRunDriver took over the run on another host and finished it. The saved transcript has the Bash tool result and the final text, but no assistant message with the Bash tool call. The live stream was correct, because the event log already held the first part of the run.
The transcript loses more than that one call. The successor's transcript is missing every chunk that the first host delivered before the restart: assistant text, complete tool calls, and the start of a tool call that was still running. A call that was still running leaves its result as an orphan role: 'tool' message with no call.
Expected: the saved transcript after a takeover is the same as the transcript of a run that did not restart.
Steps:
- Use
claudeCodeTextwithwithPersistenceandwithSandbox(sandbox, { instances, runs, durability }). - Start a run where the agent writes some text and then runs a slow tool.
- Stop the host while the tool runs. Let
sandboxRunDrivertake over the run on another host. - When the run finishes, load the thread from the message store. It holds only the chunks that the successor forwarded.
Suspected cause. On an attach, the harness adapter wraps its replay in alignedIfAttaching. alignToStoredLog suppresses the prefix that the event log already holds and yields only the rest. The wrap is inside the adapter's chatStream, so the suppressed chunks never reach the engine:
- The engine does not see the text of the prefix, so it does not add that text to the transcript.
withSandbox'sonChunkdoes not see theTOOL_CALL_START,TOOL_CALL_ARGSandTOOL_CALL_ENDof the prefix, so the tool-history recorder writes no call. The laterTOOL_CALL_RESULTarrives, and the recorder writes the result alone.
A comment in appendCall says that "a journal replay on takeover re-emits the whole stream". After alignment, that is not true.
Other effects. stripObservedToolCalls removes a result only when it also removed the result's call. So an orphan result stays in the model request of the next turn. claudeCodeText is not affected, because buildPrompt keeps only user and assistant text. I did not check the other harness adapters.
Not checked: whether withPersistence's snapshotStreaming option saves the first host's partial transcript in a form that the successor merges back.
Related: #2035 is a different takeover bug, where the reconnected client receives the rest of the run twice.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://gist.github.com/adelrodriguez/4e34cfd7224b96dfe05d554e4c0dd1e0
The test runs one chat() with withPersistence(memoryPersistence()) and withSandbox(..., { runs, durability: { adapter: fakeLog(prefix), attach: true } }). Its adapter does what claudeCodeText does: it wraps a fixed replay in alignedIfAttaching. The log already holds the chunks up to the Bash call's TOOL_CALL_END, including a first text message. Place the file in packages/ai-sandbox/tests/ and run vitest run tests/takeover-transcript.repro.test.ts in packages/ai-sandbox. Both tests fail on main:
forwarded to engine: TOOL_CALL_RESULT, TEXT_MESSAGE_START, TEXT_MESSAGE_CONTENT, TEXT_MESSAGE_END, RUN_FINISHED
saved transcript:
{ "role": "user", "content": "Run the slow job" }
{ "role": "tool", "toolCallId": "bash-1", "content": "done" }
{ "role": "assistant", "content": "Finished.", ... }
× keeps the assistant tool call, not only its result
× keeps the text the first host streamed before the restart
AssertionError: expected 'Run the slow job done Finished.' to contain 'Starting the job.'
Tests 2 failed (2)
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
🤖 Created with Claude Opus 5.5 in T3 Code
- Ngôn ngữ chính
- TypeScript
- Star
- 3.3k
- Fork
- 378
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 254
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/ai
-
openai-base: a Responses max_output_tokens cutoff ends as RUN_ERROR without usage instead of finishReason 'length'Có thể đã có người làm @tombeckenham đã nhận 8 ngày trước. Đang mởhas-pr waiting-on: maintainer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
TanStack/ai#1916 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AG-UI TOOL_CALL_RESULT metadata is dropped in the live stream reducerCó thể đã có người làm @c446984928 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-sandbox: encrypt snapshot blobs at rest with an encrypting blob store wrapperCó thể đã có người làm @AlemTuzlak đã nhận 1 ngày trước. Đang mởwaiting-on: maintainer
TanStack/ai#2062 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
withSandbox: each run's save drops the harness tool calls of earlier runsCó thể đã có người làm @tombeckenham đã nhận 1 ngày trước. Đang mởhas-pr waiting-on: maintainer
TanStack/ai#2059 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-compaction: checkpoint never reused when the store returns message keys in another orderCó thể đã có người làm @tombeckenham đã nhận 1 ngày trước. Đang mởhas-pr waiting-on: maintainer
TanStack/ai#2050 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
The sample email preview's ResizeObserver is never disconnected and keeps raising errors after leaving SettingsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:ui bug effort:S priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Typo in WSL project description on Projects pageCó thể đã có người làm @akhil9tiet đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
microsoft/opensource.microsoft.com#1066 · 1 bình luận ·
-
ArcGIS Maps SDK for JavaScript c-carousel calcite-design-tokens enhancement impact - p3 - not time sensitive needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Esri/calcite-design-system#15565 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
linkwarden/linkwarden#1891 ·
Maintainer thường phản hồi trong vòng 1 ngày