Skip to content

fix(websearch): retry transient failures and fall back to other provider - #50225

Open
DScoNOIZ wants to merge 1 commit into
anomalyco:devfrom
DScoNOIZ:websearch-resilience
Open

DScoNOIZ wants to merge 1 commit into
anomalyco:devfrom
DScoNOIZ:websearch-resilience

Conversation

@DScoNOIZ

@DScoNOIZ DScoNOIZ commented Sep 20, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #50227

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

I hit this myself: on flaky egress the Parallel search endpoint periodically dies with transport errors, and since the tool makes exactly one attempt per call (provider pinned per session), search stayed broken for the whole session.

Changes, in packages/opencode/src/tool/{mcp-websearch,websearch}.ts:

  • call() retries transient failures (3 attempts, exponential backoff + jitter, the same Effect.retry idiom used elsewhere in the repo);
  • the 25s timeout now fails instead of dying, so retries and the fallback can actually catch it (the tool boundary still dies via orDie if both providers fail);
  • if the pinned provider fails, the call falls back to the other one and reports which provider was actually used;
  • opt-in MCP handshake (OPENCODE_WEBSEARCH_HANDSHAKE=1) for providers that start rejecting session-less calls. Without the flag behavior is unchanged.

No retry is infinite: 3 attempts max, then fallback, then the error surfaces as before.

How did you verify your code works?

  • bun typecheck clean in packages/opencode;
  • bun test test/tool/websearch.test.ts: 10/10 pass;
  • live HTTP probes against search.parallel.ai: plain stateless tools/call works, initialize handshake returns a session id (verified the exact request shapes the code sends).

Screenshots / recordings

N/A (no UI change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Sep 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

websearch dies on transient Parallel transport errors with no retry or fallback

1 participant