Pool configuration: tasks, tools, sampling params, max turns
Agent pool result with per-agent findings and aggregate statistics
const pool = yield* withSharedRoot(
{ systemPrompt: RESEARCH_PROMPT, tools: toolsJson },
function*(root) {
return yield* useAgentPool({
tasks: questions.map(q => ({
systemPrompt: RESEARCH_PROMPT,
content: q,
tools: toolsJson,
parent: root,
})),
tools: toolMap,
maxTurns: 6,
});
},
);
Concurrent agent generation loop as an Effection resource
Runs N agents in parallel using a four-phase tick loop over shared BranchStore infrastructure. Each agent forks from a parent branch, generates tokens, invokes tools, and reports findings.
Four-phase tick loop:
produceSync()(no async gap)store.commit()for all produced tokensscoped()+call()Tool dispatch uses
scoped()+call()— each tool executes to completion before the next tick, ensuring exclusivellama_contextaccess (no concurrent decode).Resource semantics:
provide()suspends after all agents complete, keeping branches alive so the caller can fork from them (e.g. for verification). Branches are pruned when the scope exits — each branch'sensure()fromsetupAgenthandles cleanup automatically.For automatic branch cleanup on return, use runAgents instead.