refactor: move metacognition/ from system/ to reference/ to reduce system prompt size for subagent spawning

This commit is contained in:
Annie Tunturi
2026-03-21 09:21:27 -04:00
parent f1e2ef0eff
commit d13d445cb9
15 changed files with 183 additions and 547 deletions

View File

@@ -0,0 +1,67 @@
---
description: Community ADE SubagentDispatcher implementation - SDK-based subagent spawning
limit: 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
```typescript
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
```typescript
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
```typescript
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)