Building Sub‑Agents for a Desktop AI Companion
Description and use
Building sub‑agents for the desktop AI companion Ankita isolates tasks, caps context, and returns concise envelopes, preventing history bloat and blocking when handling multiple jobs at once.
Problem
A single AI agent on a desktop can only handle one conversation at a time, causing context ballooning and blocking when it tries to perform multiple independent tasks.
Outcome
Sub‑agents keep the parent’s context small, enforce isolation, and provide a clear, capped report for each task, improving reliability and auditability.
Workflow
- 1. Parent agent receives a user request.
- 2. Parent calls
delegate_taskwith a brief and a sub‑agent type (explore, reviewer, or worker). - 3. Sub‑agent runs its own tool loop with a depth of 1 and bounded budgets.
- 4. Sub‑agent produces a capped envelope (status, summary, final answer, tools, token usage, duration, transcript path).
- 5. Parent receives the envelope, verifies the report, and updates its state.
- 6. Parent repeats for subsequent requests, serializing workers per workspace path to avoid conflicts.
Evidence
Sooner or later, any agent like that hits the same wall: one conversation trying to do three independent jobs at once. The parent's context balloons, the work interleaves, and a long task blocks everything behind it.
A child in Ankita sees only its brief — the prompt passed to delegate_task. It cannot ask questions and cannot delegate.
When it finishes, the parent receives one result envelope: status, a summary capped at 2,000 bytes, the full final answer capped at 48,000 bytes by default, the tools used, token usage, duration, and a transcript path.
There are exactly three child types, defined in src/core/subagents/registry.mjs…
Workers are the opposite: a mutation barrier. One worker runs at a time across the whole process, keyed by the canonical workspace path…
- Record date: 2026-11-01T20:44:15.033Z