# Subagents agent guide
Schedules child runs with separate cwd/session/activity state and bounded results.
## Where to look
| Dispatch, task/result shape, limits | `mod.rs`, `dto.rs` |
| Inheritance and child paths | `config.rs`, `cwd.rs` |
| Identity profiles | `profiles.rs` |
| Worker scheduling and waiting | `scheduler.rs` |
| Child runner and result truncation | `worker.rs` |
| Selected-child steering, cancellation, retained input | `control.rs`, `worker.rs`, `../agent/steering.rs` |
| Activity tree and structured output | `activity.rs`, `output_schema.rs` |
| Regressions | `tests/`, plus profile-local tests |
## Local contracts
- `dto.rs` caps tasks at 10 and concurrent workers at 4. Default depth is 2; maximum configurable depth is 4. Check depth before scheduling, including nested tool availability.
- `resolve_child_cwd` canonicalizes before applying inherited absolute-path policy.
- `SubagentTask.identity` selects a profile; `agent` is only a label/persona, never an inferred identity.
- Profiles load from `$MC_HOME/subagents/*.md`; validate identity ids and reject symlinked profile files before prompt reads.
- Inherit settings, hooks and tool restrictions; identity filtering must also affect the child provider schema.
- Preserve stable `gN` result ids and the parent batch/task activity tree despite out-of-order completion.
- `control.rs` keys controls by full runtime activity id, including ancestry. Its 64-entry registry refuses new controls rather than evicting unacknowledged input; completed controls with pending input remain recallable. Child cancellation must not cancel parent or siblings.
- Child steering reuses agent continuation and durable append/acknowledgement boundaries. After compaction, pending steering precedes automatic `continue`; failed preparation releases unpersisted input for recall.
- Preserve bounded output, truncation markers, session references and structured serialization. Child failures remain visible in batch summaries.
- Never widen inherited cwd, tool, time, output, task or depth limits to make a child succeed.