fix(eve): recover when an OpenAI-compatible endpoint rejects the injected web_search tool - #1453
Open
lucasdoell wants to merge 1 commit into
Open
Conversation
…cted web_search tool eve injects OpenAI's provider-managed web_search tool for any BYO model whose id looks OpenAI-shaped, which makes the AI SDK add the web_search_call.action.sources include to every Responses API request. OpenAI-compatible endpoints without native web search (e.g. AWS Bedrock Mantle) reject that include with HTTP 400, failing every model call before the agent can complete a single turn. Teach the unsupported-provider-tool recovery to recognize the include rejection shape, map it back to the framework web_search tool, drop the tool, and retry the step — the same recovery flow used when a gateway fallback provider rejects web_search_20250305. The regex is anchored on the "invalid value" phrasing so supported-value enumerations and request-snapshot echoes in truncated error bodies cannot trigger a false drop. Fixes vercel#1451 Claude-Session: https://claude.ai/code/session_019EdUqspQPvUwPAUxMRvSDu Signed-off-by: Lucas Doell <lucas@lux.dev>
Contributor
|
@lucasdoell is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fixes #1451
Problem
eve auto-injects OpenAI's provider-managed
web_searchtool for any BYO model whose id looks OpenAI-shaped (resolveWebSearchBackend). When the model is actually served by an OpenAI-compatible endpoint without native web search — e.g. GPT 5.6 Sol/Luna through AWS Bedrock Mantle viacreateOpenAI({ baseURL })— the AI SDK addsinclude: ["web_search_call.action.sources"]to every Responses API request and the endpoint rejects it:{"error":{"message":"Invalid value: 'web_search_call.action.sources'. Supported values are: 'reasoning.encrypted_content'.","type":"invalid_request_error","param":"include","code":"invalid_value"}}The 400 is classified terminal and the existing unsupported-provider-tool recovery never fires (its detection is anchored on the gateway's
tool type 'X' is not supportedphrasing), so every model call fails — the agent cannot complete a single turn. The only workaround is adisableTool()file atagent/tools/web_search.tsin every agent.Solution
Extend the existing recovery flow (the one already used when a gateway fallback provider rejects
web_search_20250305) to recognize this rejection shape:model-call-error.ts:extractUnsupportedProviderToolTypesnow also matches an upstreamInvalid value: 'web_search_call.action.sources'rejection, in both the structured scan and the truncated-responseBodyraw scan. The regex is anchored on theinvalid valuephrasing so supported-value enumerations (an endpoint rejecting a different include) and request-snapshot echoes in truncated error bodies cannot trigger a false drop. That include is added by the AI SDK only when the injected OpenAI web-search tool is present, so mapping the rejection back toweb_searchis safe.provider-tools.ts: mapweb_search_call.action.sources→web_searchinUPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME.The harness then drops
web_search, retries the step once with the standard system note, and the retry no longer carries the include — agents on such endpoints self-heal instead of hard-failing.Validation
@ai-sdk/openai: withweb_searchin the tool set the SDK sends the include and the call 400s; without it, the call succeeds.disableTool()workaround); injection/detection paths unchanged onmain.data, viaresponseBodyonly, via truncated-body raw scan; negative tests for supported-value enumeration and request-echo shapes; mapping test forresolveFrameworkToolFromUpstreamType.pnpm lint,pnpm typecheck,pnpm test(unit 5600 passed, integration 567 passed) all green; changeset (patch) included.Notes