← Catalog

@herbertgao/pi-agency

Search the Agency Agents catalog and dispatch its personas to Pi subagents without loading them into context.

Extension

Install

Install with PiG

pig install npm:@herbertgao/pi-agency

Install with Pi

pi install npm:@herbertgao/pi-agency
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.5 (README.md). PiG does not review it.

@herbertgao/pi-agency

Search the Agency Agents catalog and dispatch its personas to Pi subagents without reading the catalog or persona files into the main context.

pi install npm:@herbertgao/pi-agency
git clone https://github.com/msitarzewski/agency-agents ~/.agency-agents

The catalog location is fixed at ~/.agency-agents. agency_dispatch also needs the Agent tool from @herbertgao/pi-subagents, which the @herbertgao/pi-extensions aggregate bundles. Requires Pi 0.99.0 or later.

Tools

agency_search({ queries, limit?, per_division? }) returns cards (path, name, description, score) for each query. The text form prints each card's absolute path; catalog plus path compose the same path for programmatic callers. It ranks every <division>/**/*.md file with name and description frontmatter by BM25 over name, path, and description. It returns at most limit cards per query (default 6) and per_division cards per top-level division (default 2). The repository's integrations, strategy, examples, and scripts directories are skipped.

agency_dispatch({ runs, shared?, shared_file?, subagent_type?, isolated?, model?, thinking?, max_turns?, record_dir? }) runs every runs[i].prompt as a foreground Agent call, all in parallel, and returns when they finish. Foreground calls do not queue completion notifications for the parent session.

  • {{persona}} is replaced by the body of runs[i].persona with its frontmatter removed. The file must resolve inside the catalog, symlinks included, and must not contain <persona> or </persona>.
  • {{shared}} is replaced by shared or the text of shared_file.
  • Each placeholder must appear exactly once when its value is given and must not appear otherwise. Substitution happens in one pass, so $& and placeholder-like text in inserted content stay literal.
  • Defaults are subagent_type: "general-purpose" and isolated: true, which gives subagents built-in tools only.
  • Each result includes promptSha256 for the prompt actually sent, plus the run's status, agent id, resolved model, duration, tool uses, tokens, and output. The text form repeats those statistics on the heading of a completed run.
  • All runs come back inside one tool result, so their Agent calls stay nested and get no separate transcript rows. Seat, review, and any other lane that needs its own row, its own model, or its own turn cap belongs in one Agent call per lane, not here.
  • max_turns is omitted unless you pass it, so a run decides when it is done; set it only to bound a runaway.
  • record_dir must be absolute and used by one dispatch at a time. It receives <id>.prompt.txt and <id>.return.txt with mode 0600. The call fails before any dispatch if one of those files already exists.

agency_register({ personas, tools?, extensions? }) registers catalog personas as session-scoped pi-subagents agent types over its RPC bus and returns the type names to pass as subagent_type. The persona body becomes the type's system prompt, the card name becomes the label, and the card color becomes the badge — a seat shows as MCP Builder with its color instead of general-purpose. tools defaults to "all", which inherits the session's extensions and skills the way general-purpose does, so a research persona keeps web_search, fetch_content, and MCP; "builtin" keeps only pi's built-in tools, and "none" is a structurally tool-less advisory seat. extensions: ["pi-web-access"] narrows "all" to named extension ids. Types vanish at the next session start, never shadow file-loaded agents, and need @herbertgao/pi-subagents on the event bus — an older or upstream pi-subagents answers nothing and the call fails, so the seat falls back to carrying the persona file's absolute path.

All three tools return structuredContent, so codemode scripts receive objects instead of text.

const { results } = await tools.agency_search({
  queries: ["OAuth login flows", "database migration safety"],
})
const { results: reviews } = await tools.agency_dispatch({
  shared_file: "/tmp/review/diff.patch",
  runs: results.map(({ cards: [card] }, i) => ({
    id: `expert-${i + 1}`,
    persona: card.path,
    prompt:
      "<persona>\n{{persona}}\n</persona>\n\nReview this diff:\n{{shared}}",
  })),
})