Durable resume through withPersistence never fills ctx.inputResponse for mcp_input interrupts
维护者通常 1 天内回复
@tombeckenham 已经在做这个了。
开始于 2026年10月23日。
评估
这个 Issue 还没有评估数据。
描述
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.
- 主要语言
- TypeScript
- 星标
- 3.2k
- 派生
- 372
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 274
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/ai 的其他 Issue
-
ai, ai-persistence: a nested subagent that waits runs again from the start under withPersistence可能已有人在做 @tombeckenham 于 2 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
ai-ollama: streamed chat() reports finishReason "stop" when done_reason is "length"可能已有人在做 @AlemTuzlak 于 2 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
Discriminate status-dependent record and option types (RunRecord, SessionIndexEntry, InputState, durable-only options)可能已有人在做 @jherr 于 8 天前认领。 未关闭enhancement waiting-on: maintainer
维护者通常 1 天内回复
-
move to modelschemas可能已有人在做 @jherr 于 9 天前认领。 未关闭has-pr waiting-on: maintainer
维护者通常 1 天内回复
-
chat(): sign the state of a suspended run so a resume without persistence cannot change it可能已有人在做 @AlemTuzlak 于 11 天前认领。 未关闭waiting-on: maintainer
TanStack/ai#1740 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
area:desktop bug documentation
难度 2/5 1-3 小时 新手友好度 76/100
anthropics/claude-code#104801 ·
维护者通常 1 天内回复
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
spudly/design-system#110 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefix可能已有人在做 @ItsDeadlyProgrammer 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
appsmithorg/appsmith#42471 · 1 条评论 ·
维护者通常 2 天内回复