fix(core): safely recover malformed tool input (#37698)

This commit is contained in:
Kit Langton 2026-07-18 21:52:45 -04:00 committed by GitHub
commit 57ff57595a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 876 additions and 93 deletions

View file

@ -565,6 +565,22 @@ Recent work
text: "Partial thought",
state: { itemId: "rs_failed", reasoningEncryptedContent: null },
}),
SessionMessage.AssistantTool.make({
type: "tool",
id: "hosted-completed",
name: "web_search",
executed: true,
providerState: { itemId: "call_completed" },
providerResultState: { itemId: "result_completed" },
state: SessionMessage.ToolStateCompleted.make({
status: "completed",
input: { query: "Effect" },
content: [],
structured: {},
result: { type: "json", value: { found: true } },
}),
time: { created, completed: created },
}),
SessionMessage.AssistantTool.make({
type: "tool",
id: "hosted-failed",
@ -592,6 +608,22 @@ Recent work
expect(messages[0]?.content).toEqual([
{ type: "text", text: "Partial thought" },
{
type: "tool-call",
id: "hosted-completed",
name: "web_search",
input: { query: "Effect" },
providerExecuted: true,
providerMetadata: { provider: { itemId: "call_completed" } },
},
{
type: "tool-result",
id: "hosted-completed",
name: "web_search",
result: { type: "json", value: { found: true } },
providerExecuted: true,
providerMetadata: { provider: { itemId: "result_completed" } },
},
{
type: "tool-call",
id: "hosted-failed",