Skip to content

Commit ee8e2d1

Browse files
committed
fix(parallel): move the Pi web_search Parallel request to V1 and drop any in tests
- The Pi web_search host and sandbox request builders still targeted /v1beta/search with the beta header and an objective-only body, which the V1 tool now rejects because search_queries is required. Both send the query as the single search query plus objective, with max_results under advanced_settings, so the parity test holds again - Test helpers return Record<string, unknown> instead of any
1 parent 423c0f6 commit ee8e2d1

5 files changed

Lines changed: 20 additions & 15 deletions

File tree

apps/sim/executor/handlers/pi/search/extension-source.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,20 @@ describe('provider requests', () => {
144144
expect(JSON.parse(init.body)).toEqual({ q: 'pi agent', num: 2 })
145145
})
146146

147-
it('sends the Parallel request with its beta header', async () => {
147+
it('sends the Parallel request to the V1 endpoint with the query as both query and objective', async () => {
148148
fetchMock.mockResolvedValue(jsonResponse({ results: [] }))
149149

150150
await register('parallel').execute('call-1', { query: 'pi agent', numResults: 4 })
151151

152152
const [url, init] = fetchMock.mock.calls[0]
153-
expect(url).toBe('https://api.parallel.ai/v1beta/search')
153+
expect(url).toBe('https://api.parallel.ai/v1/search')
154154
expect(init.headers['x-api-key']).toBe('key-123')
155-
expect(init.headers['parallel-beta']).toBe('search-extract-2025-10-10')
156-
expect(JSON.parse(init.body)).toEqual({ objective: 'pi agent', max_results: 4 })
155+
expect(init.headers['parallel-beta']).toBeUndefined()
156+
expect(JSON.parse(init.body)).toEqual({
157+
search_queries: ['pi agent'],
158+
objective: 'pi agent',
159+
advanced_settings: { max_results: 4 },
160+
})
157161
})
158162

159163
it('sends the Firecrawl request as a bearer token with a server-side budget', async () => {

apps/sim/executor/handlers/pi/search/extension-source.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ function buildRequest(provider, apiKey, query, numResults) {
105105
}
106106
if (provider === "parallel") {
107107
return {
108-
url: "https://api.parallel.ai/v1beta/search",
109-
headers: {
110-
"Content-Type": "application/json",
111-
"x-api-key": apiKey,
112-
"parallel-beta": "search-extract-2025-10-10",
108+
url: "https://api.parallel.ai/v1/search",
109+
headers: { "Content-Type": "application/json", "x-api-key": apiKey },
110+
body: {
111+
search_queries: [query],
112+
objective: query,
113+
advanced_settings: { max_results: numResults },
113114
},
114-
body: { objective: query, max_results: numResults },
115115
}
116116
}
117117
if (provider === "firecrawl") {

apps/sim/executor/handlers/pi/search/normalize.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ describe('buildPiSearchProviderArgs', () => {
8484
num: 3,
8585
})
8686
expect(buildPiSearchProviderArgs('parallel', query)).toEqual({
87+
search_queries: ['ts 5.9 release notes'],
8788
objective: 'ts 5.9 release notes',
8889
max_results: 3,
8990
})

apps/sim/executor/handlers/pi/search/normalize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function buildPiSearchProviderArgs(
170170
case 'serper':
171171
return { query, num: numResults }
172172
case 'parallel':
173-
return { objective: query, max_results: numResults }
173+
return { search_queries: [query], objective: query, max_results: numResults }
174174
case 'firecrawl':
175175
return { query, limit: numResults }
176176
}

apps/sim/tools/parallel/parallel.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ function searchBody(params: Record<string, unknown>) {
1818
search_queries: 'q',
1919
apiKey: API_KEY,
2020
...params,
21-
} as never) as Record<string, any>
21+
} as never) as Record<string, unknown>
2222
}
2323

2424
function extractBody(params: Record<string, unknown>) {
2525
return extractTool.request.body?.({
2626
urls: 'https://a.com',
2727
apiKey: API_KEY,
2828
...params,
29-
} as never) as Record<string, any>
29+
} as never) as Record<string, unknown>
3030
}
3131

3232
function jsonResponse(body: unknown, status = 200) {
@@ -175,7 +175,7 @@ describe('parallel_deep_research', () => {
175175
input: 'HVAC market',
176176
apiKey: API_KEY,
177177
include_domains: 'a.com',
178-
} as never) as Record<string, any>
178+
} as never) as Record<string, unknown>
179179
expect(body.task_spec).toEqual({ output_schema: { type: 'text' } })
180180
expect(body.enable_events).toBe(false)
181181
expect(body.processor).toBe('pro')
@@ -187,7 +187,7 @@ describe('parallel_deep_research', () => {
187187
input: 'HVAC market',
188188
output_format: 'auto',
189189
apiKey: API_KEY,
190-
} as never) as Record<string, any>
190+
} as never) as Record<string, unknown>
191191
expect(body.task_spec).toEqual({ output_schema: { type: 'auto' } })
192192
})
193193

0 commit comments

Comments
 (0)