Repository navigation
feat(search): fall back to credential-free providers for web search - #364
Merged
Merged
Conversation
`search_web` required a StepFun search credential, so a session using a self-configured model could not search at all: it failed with "requires a credential", or used a stale key against the StepFun endpoint and received 401/402. Search was also bound at tool creation time, so logging in during a session had no effect. Resolve the backend on every call and walk an ordered candidate chain: - The StepFun endpoint stays first whenever the current login resolves a search credential, which keeps paid users on the better path. A quota, auth, network or timeout failure falls through to the free providers instead of failing the tool. - Without a credential the paid endpoint is absent from the chain rather than attempted and failed, which skips a call that cannot succeed. - The free providers (Exa, Firecrawl, Tavily, Parallel, TinyFish) are called without a credential, in a per-call shuffled order so traffic is spread across their independent free allowances. - Selection is re-read per call from STEPCODE_SEARCH_PROVIDER, then [search] provider, then auto. An unrecognized value degrades to auto. Failures are classified by the provider's `isError` flag first, then the status code, then the body text: several providers answer HTTP 200 with an error body, and treating that as "no results" would stop the chain and hide an exhausted quota. Each failure is attributed to its provider, cooldowns skip known-bad candidates, and a rejected credential-free provider is skipped for the rest of the process. The tool contract is unchanged: same name, same input, same rendering and details fields, same permission entry.
liuedcson
requested review from
MelodyVAR,
Uking-xxx and
ZouR-Ma
as code owners
November 21, 2026 03:34
…ntries The rewrite rendered results strictly by array index and dropped entries without a URL. Both changed what the model sees for the paid endpoint: - a provider-assigned `position` was replaced with the array index, so a numbering gap was silently renumbered; - an entry without a URL was removed instead of being shown under its position and title. Restore both, and correct the `provider` option JSDoc: the environment variable takes precedence over config.toml, not the other way round. The added case pins the numbering, the URL-less entry, and the index fallback so a later refactor cannot quietly drop them again.
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.
What
search_webnow resolves its backend on every call and walks an ordered candidate chain instead of binding one StepFun endpoint at tool-creation time.Why
A session using a self-configured model could not search at all.
search_webrequired a StepFun search credential, so it either failed withrequires a credentialor used a stale key against the StepFun endpoint and received 401/402. Because the endpoint and credential were computed increateSearchWebTool, logging in during a session had no effect either.How
Chain construction
Failure classification
isErrorfirst, then the HTTP status, then the body text. Several providers answer HTTP 200 with an error body, and treating that as "no results" would stop the chain while hiding an exhausted quota. A daily ceiling reported under 429 is classified as a quota, not a burst limit.Scheduling
One shared 25s deadline covers every attempt including the handshake fallback, cooldowns skip known-bad candidates, a rejected credential-free provider is skipped for the rest of the process, and a caller cancellation stops the walk immediately.
Configuration
STEPCODE_SEARCH_PROVIDER>[search] providerinconfig.toml>auto. Supported values areauto,off,step, and the five free provider ids; any other value is treated asauto. Selection is re-read per call, so an edit applies to the next search.Compatibility
The tool contract is unchanged: same name, same
{query}input, same markdown rendering with the Sources convention, samedetailsfields (plusprovideranddegraded), same read-only permission entry, sameexecutionMode: "parallel".Stepping back to the previous behaviour needs no code change:
STEPCODE_SEARCH_PROVIDER=steppins the paid endpoint as a single-candidate chain.Validation
Measured against the live endpoints after the fix:
Scenario runs through
createSearchWebTool().execute()— 13/13 passed: each pinned provider,autowithout a credential, repeated calls on one instance,config.tomlselection, an unknown config value,off, an empty config, and a pinnedstepwithout a credential.Tests: 148 cases across 7 related files, including 11 end-to-end scenario cases that drive the tool rather than the chain builder.
pnpm run checkpasses (biome, type checks, all boundary checks).Notes
tool_call_completedis registered but has no producer in this repository, so a new event would be equally unreachable. The resultdetailscarryprovideranddegradedinstead.Review follow-up
Two review nits, both now fixed:
provideroption JSDoc listed config.toml before the environment variable. The implementation isexplicit ?? env ?? config, so the doc is corrected rather than the code.positionwas renumbered, and a URL-less entry disappeared instead of being shown asposition. title. Both are restored, and a test now pins the numbering, the URL-less entry and the index fallback.