feat: add /research command with sub-agent delegation
This commit is contained in:
@@ -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') ?? '';
|
||||
|
||||
Reference in New Issue
Block a user