Files
Redflag/reference/ade_subagent_implementation.md

1.9 KiB

description, limit
description limit
Community ADE SubagentDispatcher implementation - SDK-based subagent spawning 5000

SubagentDispatcher SDK Implementation

Completed: 2026-03-21 Commit: 03db04e - feat: replace simulateSubagent with actual SDK calls

What Was Built

Replaced the placeholder simulateSubagent() with actual Letta Code SDK calls.

Key Features

1. Dynamic SDK Import

let sdk: typeof import('@letta-ai/letta-code-sdk') | null = null;

async function getSDK(): Promise<typeof import('@letta-ai/letta-code-sdk')> {
  if (!sdk) {
    sdk = await import('@letta-ai/letta-code-sdk');
  }
  return sdk;
}

2. Model Tier Mapping

const MODEL_TIERS = {
  opus: 'kimi-k2.5',      // Complex reasoning, architecture
  sonnet: 'nemotron-3-super', // Implementation, coding
  k2: 'k2-thinking',      // Verification, edge cases
};

Selection logic:

  • architecture / design → opus (kimi-k2.5)
  • static / style → sonnet (nemotron-3-super)
  • runtime / security → k2 (k2-thinking)

3. spawnSubagent() Method

Uses actual SDK primitives:

  • SDK.createAgent() - Spawns subagent with persona + model
  • SDK.prompt() - One-shot execution with recovery
  • AbortController - Cancellation support

4. Iterative Refinement

async refineUntilConvergence(task, options): Promise<SubagentResult>

Features:

  • Configurable max iterations (default: 3)
  • Convergence detection based on result stability
  • Task refinement between iterations
  • Returns best result from all attempts

File Location

/home/ani/Projects/community-ade/community-ade-wt/mvp-unified/src/verification/executors/SubagentDispatcher.ts

Next Steps

  • Connect to Express routes for HTTP-triggered verification
  • Add result caching layer
  • Implement result streaming for long-running verifications
  • Add metrics collection (duration, success rates by model tier)