feat(websearch): batched-query schema for Parallel#28219
Open
NormallyGaussian wants to merge 4 commits into
Open
feat(websearch): batched-query schema for Parallel#28219NormallyGaussian wants to merge 4 commits into
NormallyGaussian wants to merge 4 commits into
Conversation
Adds `objective` and `additionalQueries` (min 1, max 2) to the websearch
tool schema when the resolved provider is Parallel. Mirrors the
canonical schema from docs.parallel.ai/search/best-practices: required
fields, 3-6 word query guidance, anti-chaining language in the
description.
The schema and description are gated by a new `shouldExposeParallelExtras`
helper so the fields are only shown to the model when Parallel is the
chosen provider (env override or flag). The execute-side `Parameters`
keeps both fields optional so the tool still works when Parallel is
gated out (Exa-only schema lacks them at the wire layer).
Parallel call site uses the new fields:
objective = params.objective ?? params.query
search_queries = [params.query, ...(params.additionalQueries ?? [])]
Exa call site unchanged.
Tests:
- shouldExposeParallelExtras across all env branches
- ParallelParameters schema accepts/rejects (objective and
additionalQueries required; size bounds)
- execute-side Parameters tolerates either shape
- JSON Schema snapshots for both model-facing variants and the
execute-side Parameters
- additionalQueries: drop minItems=1, keep maxItems=2. The previous required-min-1 over-constrained simple single-topic Parallel searches by forcing the model to invent variants. Parallel docs treat 2-3 total queries as a recommendation, not a hard floor. - query (Parallel mode): override description to specify keyword shape (3-6 words, no sentences). Previously the generic description allowed sentence-form input that we then routed into search_queries[0] — Parallel expects each entry to be keyword-style, so this fixes a schema/runtime mismatch that would have degraded result quality. - parameters.test.ts: drop the `websearch 1` (execute-side Parameters) JSON Schema snapshot. After this PR's refactor, the model only ever sees BaseParameters or ParallelParameters; snapshotting Parameters under "wire shape" was misleading and didn't guard the gating logic. - tests updated for the new schema shape.
6eac970 to
df545d3
Compare
1 task
Contributor
Author
|
FYI @nexxeln |
6 tasks
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.
Issue for this PR
Closes #28216
Type of change
What does this PR do?
When the websearch tool routes to Parallel, the MCP call is currently
objective: query, search_queries: [query]— the same string twice. That throws away the two things Parallel's API is designed to combine: a natural-languageobjectivefor ranking and a small batch of diverse keywordsearch_queriesfor retrieval.This PR adds
objectiveandadditionalQueries(1–2 items) to the tool schema only when Parallel is the resolved provider for the session (env override orOPENCODE_ENABLE_PARALLELflag). A new helpershouldExposeParallelExtrasdecides per-call; the Exa-only schema (BaseParameters) is unchanged. Wording on the new fields and the appended description block are lifted from docs.parallel.ai/search/best-practices — the canonical "prefer over repeated keyword searches" / "diverse, 3-6 words, no sentences" language — so the model is nudged toward one batched call instead of three chained ones.The exported
Parameterstype used byexecutekeeps both fields optional, since the actual params at runtime depend on which model-facing schema was active.How did you verify your code works?
bun test test/tool/websearch.test.ts— 23 pass, including new cases forshouldExposeParallelExtrasacross every env branch,ParallelParametersaccept/reject (objective + additionalQueries required, batch size bounds), and execute-sideParameterstolerating either shape.bun test(full opencode suite) — 2733 pass / 0 fail / 18 snapshots. New snapshots forwebsearch (base, Exa-only mode)andwebsearch (parallel mode)lock the model-facing JSON Schema for both gating outcomes.bun run typecheck— clean.bun run lint— 0 errors.minimax-m2.5-free(Zen) withOPENCODE_WEBSEARCH_PROVIDER=parallel: prompted "research what Tesla, Ford, and GM each reported for Q1 2026 earnings, especially margins". Confirmed in the dev DB that eachwebsearchpart now has a populatedobjectiveandadditionalQueriesarray, and each MCP request bundles 3 diverse queries instead of 1.Screenshots / recordings
Parallel:

Exa:

DB rows from the manual test, showing the new fields populated (one row per call; objective is a real sentence, additionalQueries has 2 diverse keyword variants):
["Tesla Q1 2026 revenue profit","Tesla Q1 2026 automotive gross margin"]["Ford Q1 2026 revenue profit","Ford Q1 2026 operating margin"]["GM Q1 2026 revenue profit","GM Q1 2026 operating margin"]Checklist