Approval resume validates null-widened history args, so approved tools fail with repairToolInput: false
维护者通常 1 天内回复
@tombeckenham 已经在做这个了。
开始于 2026年11月6日。
评估
这个 Issue 还没有评估数据。
描述
What happens
With the OpenAI adapter, an optional tool field comes back from the provider as null (strict-mode null widening). The live tool path undoes that before it validates. The approval resume path does not. It validates the arguments from the message history as they are.
So with repairToolInput: false, an approved tool fails its own input check on resume:
Input validation failed for tool bookFlight: #/date: Instance type "null" is invalid. Expected "string"., #: Property "date" does not match additional properties schema., #/date: False boolean schema.
Received arguments: {"destination":"Tokyo","date":null}
With the default repairToolInput it passes, because the repair step happens to coerce the null away.
The two events for one tool call also disagree:
TOOL_CALL_ARGSdeltas, joined:{"destination":"Tokyo","date":null}TOOL_CALL_END.input:{"destination":"Tokyo"}
An AG-UI client rebuilds the assistant tool call from the TOOL_CALL_ARGS deltas. That is the history it sends back on resume.
Expected
The resume path undoes null widening on the history arguments the same way the live path does, whatever repairToolInput is set to. Or TOOL_CALL_ARGS streams the same arguments that TOOL_CALL_END.input reports.
Repro
@tanstack/ai 1.2.0, @tanstack/ai-openai 1.1.1, Node 22, OPENAI_API_KEY set.
import { chat, toolDefinition, maxIterations } from "@tanstack/ai";
import { openaiText } from "@tanstack/ai-openai";
const bookFlight = toolDefinition({
name: "bookFlight",
description: "Book a flight",
inputSchema: {
type: "object",
properties: { destination: { type: "string" }, date: { type: "string" } },
required: ["destination"],
additionalProperties: false,
},
needsApproval: true,
}).server(async () => ({ booked: true }));
const threadId = `repro-${Date.now()}`;
const user = { role: "user", content: "Book a flight to Tokyo. I have no date yet." };
// Run 1: pauses for approval.
const run1 = [];
for await (const chunk of chat({
adapter: openaiText("gpt-4o-mini"),
messages: [user],
tools: [bookFlight],
threadId,
runId: "r1",
})) run1.push(chunk);
const { toolCallId } = run1.find((e) => e.type === "TOOL_CALL_START");
const streamedArgs = run1
.filter((e) => e.type === "TOOL_CALL_ARGS" && e.toolCallId === toolCallId)
.map((e) => e.delta)
.join(""); // {"destination":"Tokyo","date":null}
// Run 2: approve, with the history a client rebuilt from the stream.
for await (const chunk of chat({
adapter: openaiText("gpt-4o-mini"),
messages: [
user,
{
role: "assistant",
content: "",
toolCalls: [
{ id: toolCallId, type: "function", function: { name: "bookFlight", arguments: streamedArgs } },
],
},
],
tools: [bookFlight],
threadId,
runId: "r2",
parentRunId: "r1",
resume: [{ interruptId: `approval_${toolCallId}`, status: "resolved", payload: { approved: true } }],
repairToolInput: false,
agentLoopStrategy: maxIterations(3),
})) {
if (chunk.type === "TOOL_CALL_RESULT") console.log(chunk.content); // input validation error
}
Results:
| Run 2 history args | repairToolInput |
Result |
|---|---|---|
from TOOL_CALL_ARGS deltas |
false |
input validation error, tool does not run |
from TOOL_CALL_ARGS deltas |
default | tool runs |
from TOOL_CALL_END.input |
false |
tool runs |
Where it shows up
CopilotKit's built-in agent runs on chat() and sets repairToolInput: false, so tool argument errors go back to the model. Every approved tool with an optional field fails on resume there.
- 主要语言
- TypeScript
- 星标
- 3.3k
- 派生
- 378
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 253
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/ai 的其他 Issue
-
openai-base: a Responses max_output_tokens cutoff ends as RUN_ERROR without usage instead of finishReason 'length'可能已有人在做 @tombeckenham 于 9 天前认领。 未关闭has-pr waiting-on: maintainer
难度 2/5 1-3 小时 新手友好度 74/100
TanStack/ai#1916 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
feat(ai-anthropic): support native on-demand compaction可能已有人在做 @tombeckenham 今天认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
@tanstack/openai-base: strict structured output skips $defs/definitions, so recursive zod schemas are rejected可能已有人在做 @jherr 今天认领。 未关闭has-pr waiting-on: maintainer
维护者通常 1 天内回复
-
ai-sandbox: encrypt snapshot blobs at rest with an encrypting blob store wrapper可能已有人在做 @AlemTuzlak 于 1 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
Sandbox takeover: the saved transcript loses everything the first host delivered before the restart可能已有人在做 @tombeckenham 于 1 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
binding:python bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
coollabsio/orbit#72 ·
维护者通常 1 天内回复
-
Bug
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
bug needs-triage potential-regression
难度 2/5 1-3 小时 新手友好度 78/100
aws/aws-sdk-js-v3#8408 ·
维护者通常 1 天内回复