Files
docs/build/snippets/python/code-samples/dynamic-subagents-loop-eval-js.mdx
T
2026-07-29 10:28:19 +00:00

18 lines
559 B
Plaintext

```ts
// Keep dispatching rounds, deduping against what's found, until a round adds nothing.
const seen = new Set();
const found = [];
while (true) {
const { items } = await task({
description: `Find dead code. Already found: ${[...seen].join(", ") || "(none)"}.`,
subagentType: "analyzer",
responseSchema: itemsSchema, // -> { items: [{ id, file }] }
});
const fresh = items.filter((i) => !seen.has(i.id));
if (fresh.length === 0) break; // converged: nothing new
for (const i of fresh) { seen.add(i.id); found.push(i); }
}
found;
```