Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 4.49 KB

subagents.md

File metadata and controls

17 lines (14 loc) · 4.49 KB

Subagents

Claude renamed its Task tool to Agent in 2.1.63 and keeps Task(...) working as an alias. pi-code registers the tool as subagent and maps both spellings onto it, so Agent, Agent(Explore) and the legacy Task(...) all resolve. Hook payloads and matchers report the canonical Agent.

Claude-style subagents with parallel, chain, and background modes. Source: extensions/subagent/ (see also its README).

  • Built-in Explore/Plan/general-purpose agents, plus ~/.claude/agents, ~/.pi/agent/agents, and project .claude/agents/.pi/agents (scanned recursively into subfolders), merged once the project is trusted; project wins a name clash. Every .claude/agents between the working directory and the repository root is scanned, the definition closest to the working directory winning a same-name clash, as Claude documents.
  • Frontmatter: tools/disallowedTools, model (sonnet/opus/haiku/fable tier aliases or a concrete id), effort, skills preload, permissionMode: plan, maxTurns, memory, isolation: worktree, hooks (scoped to the run, Stop converted to SubagentStop at the child's own end), background: true (a single-agent ask runs it in the background even when the call did not ask for that; in parallel and chain mode it runs in the foreground with the others).
  • A scoped entry in tools: (Bash(git log:*), Read(src/**), Bash()) grants the whole tool, as in Claude, where the scope does not limit the agent. Claude still runs each call through its permission flow; pi has no such flow. An entry whose scope does not close (Bash(, Bash(foo)bar) is unrecognized and grants nothing, and the launch is refused, naming it, when nothing else in the list resolves. A scoped disallowedTools entry denies the whole tool. Rejection warnings print once per pi process.
  • Plugin agents register under Claude's scoped id plugin:name (filename fallback for a missing name); : in a non-plugin agent name rejects the file. As in Claude, a plugin agent's hooks and permissionMode are ignored, a missing description becomes Agent from <plugin> plugin, and frontmatter that does not parse loads the agent under its filename with every field ignored. Such an agent has every tool, and pi has no per-call prompt. Explore and Plan spawn with --no-context-files, the only agents that skip CLAUDE.md, per Claude.
  • SubagentStart hooks run pre-spawn through a seam so their additionalContext lands before the child's first prompt; they cannot block the spawn.
  • The agent body is the child's system prompt (replacing pi's default, as Claude replaces its own). Model order per Claude: invocation model, frontmatter model, then CLAUDE_CODE_SUBAGENT_MODEL, then pi's default. The variable alone does not move the built-in Explore and Plan agents, as Claude documents; a model their definition or the invocation names still applies.
  • A maxTurns-capped run returns its output marked as partial; a capped background run's completion notes it can be resumed by id. A tools list where no entry resolves to a tool fails the launch naming the entries instead of running tool-less.
  • SubagentStop hooks receive last_assistant_message; agent_transcript_path stays absent (a --no-session child writes no transcript).
  • memory (user/project/local) gives the child its own persistent store under .claude/agent-memory[-local], injected with Read/Write/Edit enabled, gated on auto memory; the parent conversation's memory is never loaded into a subagent, matching Claude.
  • isolation: worktree runs the child in a temporary git worktree branched from the repository's default branch; the worktree is removed when the agent made no changes and reported in the output when kept; a run that cannot get its worktree fails rather than touching the real checkout. Divergence: pi sets the child's working directory but does not police per-command escapes.
  • Parallel and chain modes (pi extensions), one nesting level; background runs with cancel and resume. A background run keeps going across /new, /resume, /fork and /reload; its completion notice and SubagentStop hooks go to the session current when it finishes, or to the next session start when none is. In a session that has not had a turn yet the notice is recorded without starting one and reaches the model with the next prompt: pi 1.1.0 sends a turn an extension starts first with no system prompt, and the session stays without one. /tasks lists runs, /agents lists the discovered roster.