Speculate
Run N candidates in parallel. Pick the best by a user-defined scorer.
import { speculate } from '@agentskit/runtime'
const { best, candidates } = await speculate({
candidates: [
{ name: 'gpt-4o', run: () => runtime1.run(task) },
{ name: 'claude', run: () => runtime2.run(task) },
{ name: 'gemini', run: () => runtime3.run(task) },
],
pick: (results) => results.reduce((a, b) => (b.score > a.score ? b : a)),
})#When to use
- Cross-model reliability on hard prompts.
- Latency reduction (fire all, take first success).
- Cost/quality trade-offs evaluated per run.
#Related
Explore nearby
- PeerAgents
Everything that runs the loop β runtime, tools, skills, delegation, durable execution, topologies, background agents, HITL, self-debug.
- PeerRuntime
Execution engine for autonomous agents β runs a ReAct loop (observe, think, act) until final answer or step limit.
- PeerMulti-Agent Delegation
Coordinate multiple specialist agents from a parent agent using directed delegation.