INNER CODE UNIT · TypeScript

executeWhile

Kong/volcano-agent-sdk · src/patterns.ts:63

export async function executeWhile(
  condition: (history: StepResult[]) => boolean,
  body: (agent: AgentBuilder) => AgentBuilder,
  history: StepResult[],
  createSubAgent: () => AgentBuilder,
  opts?: { maxIterations?: number; timeout?: number }
): Promise<StepResult[]> {
  const maxIterations = opts?.maxIterations || 10;
  const allResults: StepResult[] = [];
  let iterations = 0;
  
  while (condition(history.concat(allResults)) && iterations < maxIterations) {
    const subAgent = body(createSubAgent());
    const results = await subAgent.run();
    allResults.push(...results);
    iterations++;
  }
  

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…