fix: handle bare string for include_domains/exclude_domains in Zod schema search tools#910
Merged
Merged
Conversation
|
@simply24365 is attempting to deploy a commit to the morphic Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
miurla
approved these changes
Jul 1, 2026
miurla
left a comment
Owner
There was a problem hiding this comment.
Thanks for the fix and the clear write-up. LGTM!
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 models sometimes return
include_domains/exclude_domainsas a barestring (
"reddit.com") instead ofstring[](["reddit.com"]), causingTypeError: f.join is not a functioninsearch-section.tsx.This was observed with the Xiaomi MIMO v2.5 model (OpenAI-compatible
endpoint), which does not enforce
strict: trueon function definitions.The model can therefore produce type-invalid tool call arguments, which
Zod rejects at validation time — but the AI SDK still renders the raw
(unvalidated) input in the UI.
Changes
lib/schema/search.tsx— Replacedz.array(z.string())withz.union([z.string(), z.array(z.string())])+.transform()so thatbare strings are coerced into single-element arrays at Zod validation
time, preventing the tool call from being rejected. Applied to both
searchSchemaandstrictSearchSchemaforinclude_domainsandexclude_domains.components/search-section.tsx— AddedArray.isArrayguardbefore
.join()as defense-in-depth.Suggestion
This type of mismatch can affect any array-typed tool parameter. Consider
enabling
strict: trueon tools for providers that support it, orimplementing
repairToolCallinToolLoopAgentto automatically fix andretry failed tool calls.