feat: add /research command with sub-agent delegation

This commit is contained in:
William Valentin
2026-02-17 15:21:11 -08:00
parent 9a2f1e2bb2
commit 2b89024a71
7 changed files with 126 additions and 3 deletions
+29
View File
@@ -590,6 +590,35 @@ export function createMessageRouter(deps: {
return '';
},
delegateAgent: async (agentName: string, task: string) => {
const target = agentName.trim();
const message = task.trim();
if (!target || !message) {
return 'Usage: /research <question or task>';
}
if (!deps.agentConfigRegistry) {
return 'No agent configurations are registered. Add agent_configs.research in config.';
}
const agentConfig = deps.agentConfigRegistry.get(target);
if (!agentConfig) {
const available = deps.agentConfigRegistry.list().map((c) => c.name);
return `Agent "${target}" not found. Available agents: ${available.length > 0 ? available.join(', ') : 'none'}`;
}
const tier: ModelTier = agentConfig.modelTier ?? 'default';
const systemPrompt = agentConfig.systemPrompt
?? `You are a sub-agent named "${target}". Complete the assigned task concisely and accurately.`;
const result = await agent.delegate({
tier,
systemPrompt,
message,
maxTokens: 4096,
});
return `[Agent: ${target} | Tier: ${result.tier} | Tokens: ${result.usage.inputTokens}+${result.usage.outputTokens}]\n\n${result.content}`;
},
getElevation: () => {
const untilRaw = session.getConfig('elevation.until_ms');
const reason = session.getConfig('elevation.reason') ?? '';