Repository navigation
feat(ai-sdk): serialize tool outputs like OpenAPI responses and send files to the model - #2334
Merged
Merged
Conversation
…files to the model A default `toModelOutput` serializes outputs like OpenAPI responses, so types such as `Date`, `BigInt`, and `Set` reach the model as JSON, and sends `Blob`/`File` outputs, nested or not, as file content named by their path, such as `report/q3.pdf`. The new `serializer` option shares custom types with an OpenAPI handler, and `toModelOutput` in tool options or `aiSdkTool` meta still takes over. The TODO about a JSON Schema `converter` option is removed: tools keep leaving JSON Schema conversion to the AI SDK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BsvL9tattvbASxVptTw9kS
Contributor
|
This run was cancelled before it finished. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
orpc | e60d3b2 | Commit Preview URL Branch Preview URL |
Oct 24 2026, 02:14 PM |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/mcp
@orpc/msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
AI SDK tools get a default
toModelOutput, modeled on how the MCP integration maps outputs:OpenAPIJsonSerializer).Date,BigInt,Set,Mapand similar types now reach the model as JSON. Before, the AI SDK's own JSON round trip turnedSet/Mapinto{}, and aBigIntmade it throw.Blob/Fileoutputs, nested or not, are sent as file content.files/0/q3.pdf).serializeroption onimplementToolFactory/createToolFactorylets you share custom types with an OpenAPI handler, the same asMcpRegistrar's option.toModelOutputset in tool options oraiSdkToolmeta overrides the default.@orpc/openapibecomes a runtime dependency of@orpc/ai-sdk, for the serializer, as it already is for@orpc/mcp.The TODO about adding a JSON Schema
converteroption is removed: tools keep leaving JSON Schema conversion to the AI SDK.Notes
toModelOutputonly shapes what the model receives. The AI SDK still streams and stores the raw tool output, so aBigIntoutput can still fail UI streaming, and history rebuilt from saved UI messages loses non-JSON values and files.ReadableStreamoutput still reaches the model as{}, as with the AI SDK's own default.Testing
serializeroption, override precedence, and an end-to-endgenerateTextrun showing the file part reach the tool message.pnpm vitest run packages/ai-sdk packages/openapi tests, the roottscand the package type check,eslint,sherifandpnpm docs:validatepass.Generated by Claude Code