withSandbox: each run's save drops the harness tool calls of earlier runs
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
Framework/Library version
Server only. chat() in a Node 24 route handler. No client framework is involved.
Describe the bug and the steps to reproduce it
With withPersistence and withSandbox on one thread, run 2's save does not contain the harness tool calls of run 1. Only the tool calls of the last run survive. After a reload, every earlier run shows its text but none of its tool cards. docs/sandbox/events.md says that the tool cards come back when the user opens the thread again.
Steps:
- Use a harness adapter (for example
claudeCodeText) withmiddleware: [withPersistence(persistence), withSandbox(sandbox, { instances })]. - Run
chat()on threadt1. The harness runs one tool. The saved thread has the tool call and its result. - Run
chat()again on threadt1. The harness runs one more tool. - Load thread
t1from the message store. Run 1's tool call and result are gone. Run 2's are there.
The middleware order does not change the result.
Suspected cause. withSandbox's onConfig returns { messages: stripObservedToolCalls(config.messages) }. Its comment says that ctx.messages keeps the recorded calls and that only the model request loses them. But applyMiddlewareConfig sets this.messages = config.messages and then middlewareCtx.messages = this.messages. So the stripped list replaces the transcript. The recorder's reconcile restores only the calls of the current run. Then withPersistence's onFinish saves ctx.messages without the earlier runs' calls.
The engine already keeps a separate list for the model request: this.providerMessages = config.providerMessages ?? config.messages.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
The test runs two chat() runs with a fixed harness stream, withPersistence(memoryPersistence()), and withSandbox over a fake provider. It fails on main in both middleware orders:
× a later run keeps the tool calls of earlier runs (persistence first)
× a later run keeps the tool calls of earlier runs (sandbox first)
AssertionError: expected undefined to be defined
expect(pairOf(messages, 'call-run-1').call).toBeDefined()
Tests 2 failed | 14 passed (16)
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
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
- Lingua principale
- TypeScript
- Stelle
- 3.3k
- Fork
- 378
- Merge medio
- 1g 2h
- PR unite (30g)
- 254
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/ai
-
openai-base: a Responses max_output_tokens cutoff ends as RUN_ERROR without usage instead of finishReason 'length'Forse già presa @tombeckenham l’ha presa 8 giorni fa. Apertahas-pr waiting-on: maintainer
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
TanStack/ai#1916 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
AG-UI TOOL_CALL_RESULT metadata is dropped in the live stream reducerForse già presa @c446984928 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
ai-sandbox: encrypt snapshot blobs at rest with an encrypting blob store wrapperForse già presa @AlemTuzlak l’ha presa 1 giorno fa. Apertawaiting-on: maintainer
TanStack/ai#2062 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Sandbox takeover: the saved transcript loses everything the first host delivered before the restartForse già presa @tombeckenham l’ha presa 1 giorno fa. Apertawaiting-on: maintainer
TanStack/ai#2061 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
ai-compaction: checkpoint never reused when the store returns message keys in another orderForse già presa @tombeckenham l’ha presa 1 giorno fa. Apertahas-pr waiting-on: maintainer
TanStack/ai#2050 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
The sample email preview's ResizeObserver is never disconnected and keeps raising errors after leaving SettingsForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
area:ui bug effort:S priority:P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Typo in WSL project description on Projects pageForse già presa @akhil9tiet l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
microsoft/opensource.microsoft.com#1066 · 1 commento ·
-
ArcGIS Maps SDK for JavaScript c-carousel calcite-design-tokens enhancement impact - p3 - not time sensitive needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Esri/calcite-design-system#15565 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
linkwarden/linkwarden#1891 ·
I maintainer di solito rispondono entro 1 giorno