Add the ability to stop inference
Release rolling / release (push) Canceled after 3m53s

This commit is contained in:
Raven Scott
2026-07-30 17:29:12 -04:00
parent 6581b826cb
commit 6abc5999f2
7 changed files with 471 additions and 128 deletions
+22
View File
@@ -227,6 +227,7 @@ export function pickAgents(userText, maxAgents = 3) {
* tools: { run: (name: string, args?: object) => Promise<any> },
* query: string,
* maxAgents?: number,
* isAborted?: () => boolean,
* onAgent?: (ev: {
* id: string,
* label: string,
@@ -239,15 +240,36 @@ export function pickAgents(userText, maxAgents = 3) {
export async function runSubAgents(opts) {
const specs = pickAgents(opts.query, opts.maxAgents ?? 3)
const tools = opts.tools
const aborted = () => Boolean(opts.isAborted?.())
/** @type {Array<{ id: string, label: string, status: string, summary: string, result?: any, error?: string }>} */
const agents = []
await Promise.all(
specs.map(async (spec) => {
if (aborted()) {
agents.push({
id: spec.id,
label: spec.label,
status: 'error',
summary: 'stopped',
error: 'stopped',
})
return
}
opts.onAgent?.({ id: spec.id, label: spec.label, status: 'start' })
try {
const result = await spec.run(tools)
if (aborted()) {
agents.push({
id: spec.id,
label: spec.label,
status: 'error',
summary: 'stopped',
error: 'stopped',
})
return
}
const summary = spec.summarize(result)
const row = {
id: spec.id,