TanStack AI version
0.48.0
Framework/Library version
@tanstack/ai-client: 0.26.0 | @tanstack/ai-svelte: 0.18.3
Describe the bug and the steps to reproduce it
Server and client tools share output-available / output-error. A server tool that throws or fails output validation becomes a failed ToolResult with { error: message } and state: 'output-error', and the agent loop continues.
A client tool uses an interrupt only because the server must pause while the browser executes.
Resolving that interrupt means execution finished, not that it succeeded. Native resume should keep the same result state. What happens instead:
When the success schema rejects { error }, the client blocks the native resume as invalid-tool-output, or durable server validation rejects it when the client has no matching schema.
When the tool has no output schema, or its schema accepts { error }, the resume succeeds but reconstructs the failure as output-available.
Both outcomes lose the original result state instead of continuing the agent loop with a failed tool result.
Expected behavior
Native client-tool resume should carry ClientToolResult state across the browser-server boundary.
The interrupt can stay status: 'resolved' because execution completed. Resume metadata should distinguish:
{ state: "output-available", output: unknown }
{ state: "output-error", errorText: string }
- A known
output-error from execution, output validation, or canonicalization should resolve the pause as a failed tool result and skip the successful output schema.
resolveClientToolOutput() should remain success-only. Before local transcript mutation or resume staging, addToolResultForClientTool() should validate and canonicalize an output-available value; either failure should use the explicit output-error path.
validateCandidate() should enforce the same success invariant for direct resolutions, report either failure as invalid-tool-output, and return an already-canonical value for applyValidation() to commit.
- The server should validate
output-available against the tool schema, validate output-error against a fixed canonical error representation, and reconstruct the same failed ToolResult as server execution ({ error: message }, state: 'output-error').
- The agent loop continues instead of rejecting the resume.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/edit/vitejs-vite-xcs8bcc9?file=src%2Fmain.ts
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms & Code of Conduct
TanStack AI version
0.48.0
Framework/Library version
@tanstack/ai-client: 0.26.0 | @tanstack/ai-svelte: 0.18.3
Describe the bug and the steps to reproduce it
Server and client tools share
output-available/output-error. A server tool that throws or fails output validation becomes a failedToolResultwith{ error: message }andstate: 'output-error', and the agent loop continues.A client tool uses an interrupt only because the server must pause while the browser executes.
Resolving that interrupt means execution finished, not that it succeeded. Native resume should keep the same result state. What happens instead:
onToolCallcatches tool andaddToolResultForClientTool()errors asoutput-error.addToolResultForClientTool()also converts output-schema failures tooutput-error, then callsresolveClientToolOutput({ error: errorText }).validateInterruptResumeBatch()validates every resolved client-tool payload against the successful output schema and stores only the raw payload inclientToolResults.output-error.validateCandidate()applies the Standard Schema;applyValidation()separately converts that value to canonical JSON.applyValidation(). The outeronToolCallcatch converts that serialization failure tooutput-errorand retries resolution with{ error }.invalid-tool-output; it never becomes a failedToolResult.When the success schema rejects
{ error }, the client blocks the native resume asinvalid-tool-output, or durable server validation rejects it when the client has no matching schema.When the tool has no output schema, or its schema accepts
{ error }, the resume succeeds but reconstructs the failure asoutput-available.Both outcomes lose the original result state instead of continuing the agent loop with a failed tool result.
Expected behavior
Native client-tool resume should carry
ClientToolResultstate across the browser-server boundary.The interrupt can stay
status: 'resolved'because execution completed. Resume metadata should distinguish:output-errorfrom execution, output validation, or canonicalization should resolve the pause as a failed tool result and skip the successful output schema.resolveClientToolOutput()should remain success-only. Before local transcript mutation or resume staging,addToolResultForClientTool()should validate and canonicalize anoutput-availablevalue; either failure should use the explicitoutput-errorpath.validateCandidate()should enforce the same success invariant for direct resolutions, report either failure asinvalid-tool-output, and return an already-canonical value forapplyValidation()to commit.output-availableagainst the tool schema, validateoutput-erroragainst a fixed canonical error representation, and reconstruct the same failedToolResultas server execution ({ error: message },state: 'output-error').Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/edit/vitejs-vite-xcs8bcc9?file=src%2Fmain.ts
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms & Code of Conduct