The web service still runs research(), but each search becomes a remote task run after you create the second service. Synthesis stays on the web service.
This page follows Render API docs. Code only: searches will not finish until that service is wired up.
A. SDK on the server
In server/package.json:
"@renderinc/sdk": "^0.5.1"$cd server && npm installadded @renderinc/sdk
Import Render from @renderinc/sdk.
B. Update tasks/src/research.ts
Remove:
import { searchOne } from './search.js'Add:
import { Render } from '@renderinc/sdk'import type { ResearchEvent, SearchResult } from '../../shared/types.js'
const serviceSlug = process.env.WORKFLOW_SERVICE_SLUG ?? 'your-service-slug'const pollMs = parseInt(process.env.WORKFLOW_POLL_MS ?? '1500', 10)const render = new Render()Polling helper (paste after the constants):
async function waitForSearchTask(taskRunId: string): Promise<SearchResult> { while (true) { const details = await render.workflows.getTaskRun(taskRunId) if (details.status === 'completed') { const result = details.results?.[0] as SearchResult | undefined if (!result) throw new Error('searchOne returned no result') return result } if (details.status === 'failed' || details.status === 'canceled') { throw new Error(details.error ?? `searchOne ${details.status}`) } await new Promise((r) => setTimeout(r, pollMs)) }}Inside searches.map, replace only the searchOne call:
const started = await render.workflows.startTask( `${serviceSlug}/searchOne`, [query, spec, index], ) const result = await waitForSearchTask(started.taskRunId)taskIdentifier:{service-slug}/{task-name}.inputData: positional JSON array matchingsearchOne(query, spec, index).started.taskRunId: available immediately fromstartTask.
Leave onEvent, buildQueries, synthesize, and the Promise.all structure unchanged.
Push
$npm run buildBuild succeeded at repo root$git add -A && git commit -m "Dispatch searchOne via task-run SDK"[main abc1234] Dispatch searchOne via task-run SDK$git pushTo github.com:YOUR_GITHUB_USER/workshop-demo.git
What you learned
- Server imports Render from @renderinc/sdk
- startTask fires remote runs; getTaskRun polls until terminal status
- Four parallel dispatches still use Promise.all from the web process