withSandbox: each run's save drops the harness tool calls of earlier runs
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.3k
- Forks
- 378
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 254
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/ai
-
openai-base: a Responses max_output_tokens cutoff ends as RUN_ERROR without usage instead of finishReason 'length'Posiblemente ocupada @tombeckenham la tomó hace 8 días. Abiertohas-pr waiting-on: maintainer
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
TanStack/ai#1916 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
AG-UI TOOL_CALL_RESULT metadata is dropped in the live stream reducerPosiblemente ocupada @c446984928 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
ai-sandbox: encrypt snapshot blobs at rest with an encrypting blob store wrapperPosiblemente ocupada @AlemTuzlak la tomó hace 1 día. Abiertowaiting-on: maintainer
TanStack/ai#2062 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Sandbox takeover: the saved transcript loses everything the first host delivered before the restartPosiblemente ocupada @tombeckenham la tomó hace 1 día. Abiertowaiting-on: maintainer
TanStack/ai#2061 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
ai-compaction: checkpoint never reused when the store returns message keys in another orderPosiblemente ocupada @tombeckenham la tomó hace 1 día. Abiertohas-pr waiting-on: maintainer
TanStack/ai#2050 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/ai
Issues similares
-
The sample email preview's ResizeObserver is never disconnected and keeps raising errors after leaving SettingsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
area:ui bug effort:S priority:P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Typo in WSL project description on Projects pagePosiblemente ocupada @akhil9tiet la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
microsoft/opensource.microsoft.com#1066 · 1 comentario ·
-
ArcGIS Maps SDK for JavaScript c-carousel calcite-design-tokens enhancement impact - p3 - not time sensitive needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Esri/calcite-design-system#15565 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
linkwarden/linkwarden#1891 ·
Los mantenedores suelen responder en 1 día