What This Example Shows
- The
BatchedGridWorkflowendpoint, which runs every agent against every task in parallel - A practical financial-analysis use case: two ETF analysts (risk + quant) across two sector queries (energy + semis)
- How to parse the per-task, per-agent output grid
BatchedGridWorkflow is a fan-out × fan-out primitive. If you give it N agents and M tasks, you get N × M independent agent runs in parallel — perfect for “analyze each of these tickers using each of these specialists” workloads.Step 1: Setup
Step 2: Build the Grid
Two specialists, two tasks → four parallel agent runs.Step 3: Call the Endpoint
The/v1/batched-grid-workflow/completions endpoint is async-friendly. Use httpx.AsyncClient to avoid blocking your event loop.
Step 4: Parse the Output
The response carries one entry per task; each entry is a dict keyed by agent name.Output shape:
outputs[task_index][agent_name] = response. If you flatten this into a 2-D grid (rows = tasks, columns = agents), every cell is an independent analyst opinion you can compare side-by-side.When To Use Batched Grid
Batched Grid is the right choice when each task is independent — no shared state, no inter-agent communication, just maximum parallelism.