Magent uses durable child-agent jobs for collaborative agent work. This replaces the old one-shot delegate tool with a small lifecycle that the root agent can coordinate explicitly.
The public child-agent tool surface is:
| Tool | Purpose |
|---|---|
spawn_agent |
Start a child-agent job and return a stable job id. |
send_agent_message |
Send follow-up input to an existing child job. |
wait_agent |
Wait for one or more jobs and return status/result data. |
list_agents |
List child jobs for the current parent session. |
close_agent |
Close a job and abort its live request when present. |
These tools share the agent permission key. The old delegate tool is not kept as a compatibility wrapper.
magent-agent-job.el defines magent-agent-job, the durable record for a child job. Each job stores:
idparent-session-idagent-nametask-namestatuspromptcreated-atupdated-attranscriptresulterrormetadataValid statuses are queued, running, waiting, completed, failed, closed, and cancelled.
The parent magent-session persists child jobs in its agent-jobs slot. Runtime-only state for active loops lives in magent-tools--agent-job-runtimes, keyed by job id. This keeps parent session JSON sufficient for resume/inspection while avoiding serializing live request handles.
spawn_agent creates a magent-agent-job in the parent session.magent-agent-loop.el.The provider boundary remains gptel-request through magent-llm-gptel.el. Magent owns orchestration, tool dispatch, persistence, abort behavior, and child-job coordination.
Child jobs inherit the parent request context where practical:
magent-child-agent-max-depth controls recursive spawning. The default allows direct children and blocks recursive child spawning.
The parent *magent* buffer renders compact lifecycle blocks as #+begin_agent / #+end_agent. Full child prompt, metadata, result/error, and transcript state remain inspectable with:
M-x magent-show-agent-transcriptC-c m jmagent-resume-session restores persisted agent-jobs with the parent session. Active request handles are not restored after Emacs restart, but saved job metadata, result/error state, and transcripts remain available for inspection.
This lifecycle intentionally preserves Magent’s Emacs-native workflow:
emacs_evalCodex sandbox, seatbelt, bubblewrap, and shell-isolation parity are out of scope.