@odradekk/vera-subagents
Subagent orchestration for Vera agent (explorer, librarian, thinker, worker)
Package details
Install @odradekk/vera-subagents from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@odradekk/vera-subagents- Package
@odradekk/vera-subagents- Version
0.3.0- Published
- Jun 12, 2026
- Downloads
- 192/mo · 166/wk
- Author
- odradekk
- License
- MIT
- Types
- extension
- Size
- 290.8 KB
- Dependencies
- 0 dependencies · 4 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
vera-subagents
Purpose
Provide an in-process SDK-based subagent tool for Vera. The current version runs delegated work in an isolated in-memory Pi AgentSession, returns the final answer to the parent agent, and exposes execution details in the tool's expandable TUI view.
Registered tools
subagent— run one delegated task in an isolated SDK subagent session; supports foreground and background execution with expandable TUI detailssubagent_status— inspect queued, running, and recently completed background subagent jobssubagent_cancel— cancel one background subagent job or all active background jobssubagent_inspect— inspect a persisted subagent run by runId
Registered commands / UI
/subagents— show a Vera-style detailed status report for the subagent system, including registry discovery, runtime surface, and background jobs/subagents cancel <jobId|all>— cancel one background job or all active jobs, then show the updated detailed report- TUI session status entry
subagents— compact live indicator for queued/running/finished background jobs - TUI subagent cards above the editor — live foreground/background run cards with Alt+1…9 focus overlays for details
YAML-defined subagents
Subagent definitions are loaded from:
~/.pi/agent/subagents/*.yaml- nearest
.pi/subagents/*.yamlwalking up from the current cwd
Supported YAML fields:
name— unique subagent name; duplicates are rejectedmodel— child model inprovider/modelformat; empty means inherit the current parent modeleffort— child thinking strength (off,minimal,low,medium,high,xhigh); empty means inherit the current parent thinking leveldescription— shown to the parent LLM so it knows when this subagent is appropriatesystem— fully replaces the subagent base system prompt when presentPromptorprompt— prepended before the delegated task texttools— built-in tool allowlist; empty means all built-in tools (read,bash,edit,write,grep,find,ls)extensionTools— extension tool allowlist; empty means extension discovery stays disabled in child sessionsskills— skill allowlist; empty means all discovered skills from the child session loadervisible— optional boolean; defaults totrue. Whenfalse, Vera does not see the definition in its subagent catalog and cannot call it through thesubagenttool
Example:
name: scout
model: anthropic/claude-sonnet-4-5
effort: medium
description: Fast repository reconnaissance for code lookup and evidence gathering
system: |
You are a focused reconnaissance subagent.
Gather evidence and answer concisely.
prompt: |
Prefer quick inspection over broad rewrites.
tools:
- read
- grep
- find
- ls
skills: []
visible: true
Current scope
- single subagent execution per tool call
- in-process SDK session, not subprocess execution
- named YAML-defined subagents or generic ad-hoc delegation
background: trueon the tool call to let a child keep running asynchronously- completion notification injected back into the main session when a background job finishes
- cancellation for queued/running background jobs
/subagentscommand and TUI status indicator for quick inspection- custom expandable TUI renderer for execution details
Tool-call overrides
model— optional model override inprovider/idform; takes precedence over the YAML definition'smodelfield.thinkingLevel— optional effort override (off|minimal|low|medium|high|xhigh); takes precedence over both YAMLeffortand the inherited main-agent level.- Omitting either parameter preserves the existing YAML/inherited fallback behavior.
Persistence & resume
Each run persists a compact run.json plus its SDK session file under the agent home, independent of the project working directory:
- Location:
~/.pi/agent/state/subagents/<runId>/. The root is the resolved Pi agent directory (PI_AGENT_DIRoverride, then module-path discovery, then~/.pi/agent), never the current project cwd. The subagent's own working directory is a separate concern and is unaffected. run.jsonrecords phase, task, selected agent config, usage, and timeline, alongside the session file path; the SDK session file holds the conversation needed to reopen the run.- Resume an interrupted run with the
subagenttool'sresumeRunId(mutually exclusive withtask/agent/model/thinkingLevel/systemPrompt/cwd). The working directory is restored from the persisted run, not the caller's cwd. - Inspect a persisted run with
subagent_inspect(runId). Both accept an optionalresumeArtifactsDir/artifactsDiroverride for runs stored outside the default path. - A startup sweep removes completed runs after 7 days and interrupted runs after 30 days.
Non-goals
- parallel or chained subagents
- session focus switching into a fully separate child TUI
- project/user agent markdown discovery
- memory writeback from child sessions
Design notes
- Child sessions always disable theme and prompt-template discovery. Extension discovery is disabled by default; when a definition lists
extensionTools, only those named extension tools are re-enabled and passed intocreateAgentSessionalongside the selected built-in tools. - When
hashline.enabledis set invera-theme.json, child sessions install the same hash-anchoredread/editpair as the main agent, passed viacustomToolstocreateAgentSession, soLINE#IDanchors stay consistent across parent and delegated agents. The implementation lives invera-themeand is imported through its public barrel. - YAML definitions specialize the child via model selection, thinking effort, system prompt replacement, prompt prefixing, built-in tool allowlists, extension tool allowlists, skill allowlists, and optional Vera-side visibility control through
visible. - Initial runs persist through
SessionManager.create(...), writing the SDK session file into the run's artifacts directory so an interrupted run can be reopened withSessionManager.open(...)on resume. See "Persistence & resume" for the on-disk layout. - The parent tool stores a compact execution timeline in
detailsso the current TUI can render it in collapsed and expanded states.
Smoke
npm run smoke- from project root:
node scripts/smoke-all.mjs
Debugging
- Verify the tool is registered from
./packages/vera-subagents. - Place a simple YAML file in
~/.pi/agent/subagents/and reload. - Run
subagentwithagent: "name"and a bounded task. - Use
background: truewhen the child should continue asynchronously while the main agent proceeds. - Run
subagent_statusfor a compact tool response, or/subagentsfor a fuller Vera-style system status report. - Run
subagent_cancelor/subagents cancel <jobId|all>to stop background work that is no longer wanted. - Watch the
subagentsTUI status entry for a compact live job indicator. - Expand the tool result or background notification in the TUI to inspect task, cwd, selected tools, selected skills, timeline, and final output.
- If execution fails, inspect
details.errorand YAML parse/duplicate warnings first.
Loaded through agent/settings.json as ./packages/vera-subagents.