Skip to content
Website ↗

How the five castes divide work ​

Codant uses caste for a role and agent for a running instance. One local daemon maintains task cards and signals while agents perform separate jobs. The worker responsible for a parent task can propose subtasks, the runtime decides which ones can run, and the Queen manages new instances. Multiple model instances can investigate, execute, or review in parallel, with their results traceable through a shared record.

Roles and capacity ​

Built-in casteResponsibilityConfigured concurrency limit
Queen queenRegisters and starts new instances, handles cancellation, and reclaims eligible idle instances1
Scout scoutUses read-only tools to locate code and tests and returns findings to its parent task4
Worker workerExecutes within granted tools and write scope, or delegates well-scoped subtasks4
Soldier soldierReviews candidate diffs in a separate context and records structured findings2
Nurse nurseProcesses session and task memory in the background and extracts knowledge for later tasks1

BUILTIN_CASTES defines these limits. AntRegistry also caps the number of registered handles at 16 and checks that the parent exists and the child depth is allowed. Subtask scheduling has its own limits, with source defaults of three parallel subagents and 20 turns per subtask. Actual concurrency is constrained by these limits together with write scope, model budget, and alarms.

The opening animation uses a hunt formation to illustrate several roles working together. The runtime's built-in castes are the five in the table. See packages/core/src/ant/caste.ts:53, packages/core/src/ant/registry.ts:27, packages/core/src/ant/registry.ts:83, and packages/core/src/ant/scheduler.ts:23.

Who decides what runs next ​

In the import and export encoding example, the daemon accepts the goal and starts the worker responsible for the root task. That worker holds the card and has the acceptance criteria. It can request a scout or worker subtask through spawn_ant, with a description, kind, write targets, and turn budget. The runtime binds the parent execution identity, checks permissions and scope, adds the new card as a dependency, and decides whether to dispatch, queue, or reject it.

When dispatch is allowed, the registration entry point can call QueenAnt.spawn to obtain the new handle. The Queen checks capacity and lineage through the registry, records spawning, and handles interrupt and idle reclamation. ScoutSubtasks.evaluateAndDispatch computes the dispatch decision. The authorized agent instances do the model work.

See delegateToolSpecs and spawnSubtask in packages/core/src/ant/delegate.ts:134 and packages/api/src/scout-subtasks.ts:540. For registration, dispatch, and reclamation, see packages/api/src/scout-ant-registration.ts:18, packages/api/src/scout-subtasks.ts:407, packages/core/src/ant/queen.ts:80, and packages/core/src/ant/queen.ts:259.

How findings reach other agents ​

A scout can return findings to its parent task, and the recorded terminal result can be queried. Later dispatch can use trail and doubt on the pheromone bus. For example, if import and export use the same encoding helper, returning that finding lets the parent revise the subtasks' scope. The decision and actual outcomes are both recorded.

For a direct discussion, tasks with collaboration tools enabled can message a direct parent, direct child, or sibling in the same task tree. The daemon binds the sending task, lease generation, and request ID. Retrying with the same request ID, target, and text retrieves the original record. Message acceptance, storage in history, and inclusion in a model request are separately observable. Message contents are part of the working context, while actual execution authority controls tool permissions.

See finalizeSubtask and ScoutCollaboration.sendMessage in packages/api/src/scout-subtask-finalization.ts:25 and packages/api/src/scout-collaboration.ts:142. For history storage and model submission confirmation, see packages/api/src/scout-collaboration.ts:319 and packages/api/src/scout-collaboration.ts:339. Read about directed messages and memory

Why review and memory have separate entry points ​

A Soldier reads the task card and candidate diff, then returns its review report from a separate model request. This keeps the executor's process and the reviewer's observations independently traceable. Publication also depends on the selected checks, current execution identity, and approval. The Nurse works through the background memory pipeline on jobs from finished tasks or closed sessions, extracting lessons for later context.

See reviewDiff, ScoutReview.review, and scheduleTaskMemory in packages/core/src/ant/soldier.ts:59, packages/api/src/scout-review.ts:101, and packages/api/src/scout-memory.ts:655. See execution through delivery

Source references identify symbols and lines in the Codant development version.