fix(core): recover malformed tool input

This commit is contained in:
Dustin Deus 2026-07-18 19:13:52 +00:00
commit 7840a0d378
8 changed files with 109 additions and 16 deletions

View file

@ -64,6 +64,25 @@ describe("ToolStream", () => {
}),
)
it.effect("classifies malformed tool input with its raw arguments", () =>
Effect.gen(function* () {
const tools = ToolStream.start(ToolStream.empty<number>(), 0, {
id: "call_1",
name: "lookup",
input: '{"query":"partial',
})
const error = yield* ToolStream.finish(ADAPTER, tools, 0).pipe(Effect.flip)
expect(error).toBeInstanceOf(LLMError)
expect(error.reason).toMatchObject({
_tag: "InvalidProviderOutput",
source: "tool-input",
toolName: "lookup",
raw: '{"query":"partial',
})
}),
)
it.effect("preserves providerExecuted and clears all tools", () =>
Effect.gen(function* () {
const first: ToolStream.State<number> = ToolStream.start(ToolStream.empty<number>(), 0, {