feat(subagents): complete queue, budgets, audit, and inspection controls

This commit is contained in:
William Valentin
2026-02-26 13:28:10 -08:00
parent b679261683
commit 3cc9e16ef5
23 changed files with 741 additions and 51 deletions
+27
View File
@@ -25,7 +25,12 @@ describe('subagent tools', () => {
id: 'planner',
agent: 'research',
tier: 'complex',
queueMode: 'followup',
toolProfile: 'minimal',
traceId: 'trace-planner',
messageCount: 0,
completedTurns: 0,
pendingCount: 0,
createdAt: 1,
updatedAt: 1,
busy: false,
@@ -36,7 +41,12 @@ describe('subagent tools', () => {
id: 'planner',
agent: 'research',
tier: 'complex',
queueMode: 'followup',
toolProfile: 'minimal',
traceId: 'trace-planner',
messageCount: 2,
completedTurns: 1,
pendingCount: 0,
createdAt: 1,
updatedAt: 2,
busy: false,
@@ -60,6 +70,8 @@ describe('subagent tools', () => {
agent: 'research',
subagentId: 'planner',
tier: undefined,
queueMode: undefined,
toolProfile: undefined,
systemPrompt: undefined,
});
expect(mockController.send).toHaveBeenCalledWith('planner', 'Create a checklist');
@@ -72,7 +84,12 @@ describe('subagent tools', () => {
id: 'planner',
agent: 'research',
tier: 'complex',
queueMode: 'followup',
toolProfile: 'minimal',
traceId: 'trace-planner',
messageCount: 4,
completedTurns: 2,
pendingCount: 0,
createdAt: 1,
updatedAt: 3,
busy: false,
@@ -83,7 +100,12 @@ describe('subagent tools', () => {
id: 'planner',
agent: 'research',
tier: 'complex',
queueMode: 'followup',
toolProfile: 'minimal',
traceId: 'trace-planner',
messageCount: 4,
completedTurns: 2,
pendingCount: 0,
createdAt: 1,
updatedAt: 3,
busy: false,
@@ -96,7 +118,12 @@ describe('subagent tools', () => {
id: 'planner',
agent: 'research',
tier: 'complex',
queueMode: 'followup',
toolProfile: 'minimal',
traceId: 'trace-planner',
messageCount: 4,
completedTurns: 2,
pendingCount: 0,
createdAt: 1,
updatedAt: 3,
busy: false,
+19
View File
@@ -1,11 +1,17 @@
import type { Tool, ToolResult } from '../types.js';
import type { ToolProfile } from '../../config/schema.js';
import type { ModelTier } from '../../models/router.js';
interface SubagentSessionSummary {
id: string;
agent: string;
tier: ModelTier;
queueMode: 'followup' | 'interrupt';
toolProfile: ToolProfile;
traceId: string;
messageCount: number;
completedTurns: number;
pendingCount: number;
createdAt: number;
updatedAt: number;
busy: boolean;
@@ -17,6 +23,8 @@ interface SubagentController {
subagentId?: string;
tier?: ModelTier;
systemPrompt?: string;
queueMode?: 'followup' | 'interrupt';
toolProfile?: ToolProfile;
}): SubagentSessionSummary;
send(subagentId: string, message: string): Promise<{
content: string;
@@ -40,6 +48,8 @@ interface SpawnArgs {
subagent_id?: string;
tier?: ModelTier;
system_prompt?: string;
queue_mode?: 'followup' | 'interrupt';
tool_profile?: ToolProfile;
task?: string;
}
@@ -62,7 +72,12 @@ function formatSummary(summary: SubagentSessionSummary): string {
`id=${summary.id}`,
`agent=${summary.agent}`,
`tier=${summary.tier}`,
`queue=${summary.queueMode}`,
`profile=${summary.toolProfile}`,
`trace=${summary.traceId}`,
`turns=${summary.completedTurns}`,
`messages=${summary.messageCount}`,
`pending=${summary.pendingCount}`,
`busy=${summary.busy ? 'yes' : 'no'}`,
].join(' ');
}
@@ -81,6 +96,8 @@ export function createSubagentTools(controller: SubagentController): Tool[] {
agent: { type: 'string', description: 'Agent profile name from agent_configs (e.g. research, coder).' },
subagent_id: { type: 'string', description: 'Optional custom subagent session ID.' },
tier: { type: 'string', description: 'Optional model tier override (fast|default|complex|local).' },
queue_mode: { type: 'string', description: 'Optional queue mode override (followup|interrupt).' },
tool_profile: { type: 'string', description: 'Optional tool profile override (minimal|messaging|coding|full).' },
system_prompt: { type: 'string', description: 'Optional system prompt override for this subagent session.' },
task: { type: 'string', description: 'Optional initial task to run right after spawn.' },
},
@@ -93,6 +110,8 @@ export function createSubagentTools(controller: SubagentController): Tool[] {
agent: args.agent,
subagentId: args.subagent_id,
tier: args.tier,
queueMode: args.queue_mode,
toolProfile: args.tool_profile,
systemPrompt: args.system_prompt,
});