9c226948d3
Add optional ttl field to BackgroundTask/LaunchInput. Council launcher passes COUNCIL_MEMBER_TTL_MS (2 hours) per member. Task poller uses task.ttl ?? TASK_TTL_MS, replacing the blanket TTL_EXEMPT_AGENTS bypass for council members with a bounded timeout. Co-authored-by: Vacbo <2445>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import type { BackgroundManager } from "../../features/background-agent"
|
|
import type { BackgroundTask } from "../../features/background-agent/types"
|
|
import type { CouncilMemberConfig } from "../../config/schema/athena"
|
|
import { parseModelString } from "../delegate-task/model-string-parser"
|
|
import { COUNCIL_MEMBER_KEY_PREFIX } from "../../agents/builtin-agents/council-member-agents"
|
|
import { COUNCIL_DEFAULTS } from "../../agents/athena"
|
|
|
|
export interface CouncilLaunchContext {
|
|
parentSessionID: string
|
|
parentMessageID: string
|
|
parentAgent?: string
|
|
}
|
|
|
|
interface LaunchOutcome {
|
|
member: CouncilMemberConfig
|
|
task: BackgroundTask
|
|
}
|
|
|
|
/**
|
|
* Launches a single council member as a background task.
|
|
* The agent key follows the "Council: <name>" pattern used by council-member-agents.ts.
|
|
*/
|
|
export async function launchCouncilMember(
|
|
member: CouncilMemberConfig,
|
|
prompt: string,
|
|
manager: BackgroundManager,
|
|
context: CouncilLaunchContext,
|
|
): Promise<LaunchOutcome> {
|
|
const parsed = parseModelString(member.model)
|
|
if (!parsed) {
|
|
throw new Error(`Invalid model format: "${member.model}" (expected "provider/model-id")`)
|
|
}
|
|
|
|
const agentKey = `${COUNCIL_MEMBER_KEY_PREFIX}${member.name}`
|
|
const memberName = member.name ?? member.model
|
|
|
|
const task = await manager.launch({
|
|
description: `Council member: ${memberName}`,
|
|
prompt,
|
|
agent: agentKey,
|
|
parentSessionID: context.parentSessionID,
|
|
parentMessageID: context.parentMessageID,
|
|
parentAgent: context.parentAgent,
|
|
writeOutputToFile: true,
|
|
model: {
|
|
providerID: parsed.providerID,
|
|
modelID: parsed.modelID,
|
|
...(member.variant ? { variant: member.variant } : {}),
|
|
},
|
|
ttl: COUNCIL_DEFAULTS.COUNCIL_MEMBER_TTL_MS,
|
|
})
|
|
|
|
return { member, task }
|
|
}
|