Durable resume through withPersistence never fills ctx.inputResponse for mcp_input interrupts
Los mantenedores suelen responder en 1 día
@tombeckenham ya está trabajando en esto.
Desde el 23/10/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
TanStack AI version
@tanstack/ai 1.0.0 (also seen in 0.69.0)
Framework/Library version
Node.js 24, server-side chat() with withPersistence; no framework involved
Describe the bug and the steps to reproduce it
A server tool that pauses on an input request gets its answer on ctx.inputResponse when the next run is resumed from the messages the client sends. When the run is resumed through withPersistence (the durable path, messages: [] and the stores rebuild the thread), the answer never reaches ctx.inputResponse. The tool is called again with inputResponse undefined, so it asks the same question again.
Steps
- A server tool throws an input request on its first call and reads the answer on the second:
import { toolDefinition } from '@tanstack/ai'
import { z } from 'zod'
const askCity = toolDefinition({
name: 'ask_city',
description: 'Ask the user which city to use',
inputSchema: z.object({}),
}).server(async (_args, ctx) => {
if (ctx.inputResponse?.status === 'resolved') {
return { city: (ctx.inputResponse.payload as { value: string }).value }
}
throw Object.assign(new Error('Input required'), {
name: 'MCPInputRequiredError',
kind: 'form',
request: {
message: 'Which city?',
requestedSchema: {
type: 'object',
properties: { value: { type: 'string' } },
required: ['value'],
},
},
})
})
-
Run it under
withPersistence. The first run ends withRUN_FINISHEDand aninterruptoutcome whose item id ismcp_input_<toolCallId>, and the stores park it. -
Resume with the answer, the way a durable continuation does:
chat({
adapter,
messages: [], // the stores own the history
threadId,
runId: nextRunId,
parentRunId: interruptedRunId,
resume: [
{
interruptId: `mcp_input_${toolCallId}`,
status: 'resolved',
payload: { value: 'Paris' },
},
],
tools: [askCity],
middleware: [withPersistence({ /* stores */ })],
})
Expected: askCity is called again with ctx.inputResponse set to { status: 'resolved', payload: { value: 'Paris' } }, as it is on the ephemeral resume.
Actual: ctx.inputResponse is undefined, so the tool throws the same input request again and the run parks a second time.
Where it happens
I found this by reading the source, not by bisecting. In src/activities/chat/index.ts at 1.0.0:
applyEphemeralInterruptResume(around line 5253) collects themcp_input_*ids of the pending server tool calls and copies each resolution intoresumeInputResponses(around line 5427). That map is whatexecuteToolCallsreads to setctx.inputResponse.applyResumeToolState(around line 5614), which applies theresumeToolStatethat middleware such aswithPersistencehands back fromonConfig, copiesgenericInterruptsintoresumeGenericInterruptsbut never intoresumeInputResponses.
So the mcp_input_* resolution survives the durable resume as a generic interrupt resolution, but the tool it belongs to never sees it. A possible fix is for the durable path to map mcp_input_<toolCallId> resolutions to resumeInputResponses the same way the ephemeral path does.
Workaround: read the resolution out of the stores and pass it to the tool through chat({ context }), keyed by tool call id.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
No sandbox; the snippets above are the minimal shape, and the source locations show the gap.
Do you intend to try to help solve this bug with your own PR?
No, because I don't have time to dive into it
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.2k
- Forks
- 372
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 266
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
-
ai, ai-persistence: a nested subagent that waits runs again from the start under withPersistencePosiblemente ocupada @tombeckenham la tomó hace 3 días. Abiertowaiting-on: maintainer
TanStack/ai#1878 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
ai-ollama: streamed chat() reports finishReason "stop" when done_reason is "length"Posiblemente ocupada @AlemTuzlak la tomó hace 4 días. Abiertowaiting-on: maintainer
TanStack/ai#1852 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Discriminate status-dependent record and option types (RunRecord, SessionIndexEntry, InputState, durable-only options)Posiblemente ocupada @jherr la tomó hace 10 días. Abiertoenhancement waiting-on: maintainer
TanStack/ai#1799 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
move to modelschemasPosiblemente ocupada @jherr la tomó hace 11 días. Abiertohas-pr waiting-on: maintainer
TanStack/ai#1788 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
chat(): sign the state of a suspended run so a resume without persistence cannot change itPosiblemente ocupada @AlemTuzlak la tomó hace 12 días. Abiertowaiting-on: maintainer
TanStack/ai#1740 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/ai
Issues similares
-
type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 1 día
-
0️⃣ phase/new
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
microsoft/playwright#43640 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100