magi-code 0.103.0

Repository-aware CLI coding agent for terminal work
Documentation
<!-- Generated by generate-agent-docs; preserve verified project-specific guidance when regenerating. -->
# Subagent guide

Parent: [source guide](../AGENTS.md).

Bounded child runs with separate cwd/session/activity state and bounded results.

## Where to look

| Change | Owner |
| --- | --- |
| Dispatch/task input and limits | `../subagents.rs`, `dto.rs`; shared result/status/batch bound: `../output/subagent_result.rs` |
| Inheritance and canonical child cwd | `config.rs`, `cwd.rs` |
| Identity profile discovery | `profiles.rs` |
| Scheduling/waiting | `scheduler.rs` |
| Child runner/setup/results/compaction/schema | `worker.rs`, `worker/{child_agent,setup,results,compaction,schema}.rs` |
| Selected-child steering/cancellation/recall | `control.rs`, `worker.rs`, `../agent/steering.rs` |
| Activity tree and structured serialization | `activity.rs`, `output_schema.rs` |
| Host-owned task facts before delivery/truncation | `telemetry.rs`; schema/selection: `../output/tool_card/task_telemetry.rs` |

## Local contracts

- Shared `MAX_SUBAGENT_TASKS` caps batches at 10; `dto.rs` validates inputs and caps concurrency at 4. Depth defaults to 2, configurable maximum 4. Check depth before scheduling and nested tool advertisement.
- Canonicalize child cwd before inherited absolute-path policy. Inherit settings/hooks/tool restrictions; identity filtering must affect provider schemas too.
- `SubagentTask.identity` selects profile; `agent` is label/persona, never inferred identity. Profiles come from `$MC_HOME/subagents/*.md`; validate IDs and reject symlinked profile files before reads.
- `mode: inspect` is independent of identity/label. Persist fixed task/tool ceiling before execution through `../sessions/task_scope.rs` and `../tools/ceiling.rs`. Summaries/steering cannot upgrade it; require a separately authorized task.
- Client tools inherit registry handles, not authority: bind actual task/activity identity, deny inspection, and persist allowed descriptor fingerprints. Missing legacy grants (including absent task scope) never admit client execution.
- Keep stable `gN` IDs and parent batch/task tree despite out-of-order completion. Bounded/truncated output, session references and child failures remain explicit in results.
- Controls use full activity identity including ancestry. The 64-entry registry refuses new controls instead of evicting unacknowledged input; completed controls with pending input remain recallable. Child cancellation cannot cancel parent/siblings.
- Steering uses agent continuation and durable append/acknowledgement. Pending steering precedes automatic `continue` after compaction; failed preparation releases unpersisted input for recall.
- Never widen inherited cwd/tool/time/output/task/depth bounds to make child succeed.