Skip to content

feat: proactive background subagent delegation (TaskWait lifecycle, fixer, permission scopes) - #4

Merged
vastsa merged 6 commits into
vastsa:mainfrom
Tioit-Wang:feat/proactive-subagents
Aug 15, 2026
Merged

vastsa merged 6 commits into
vastsa:mainfrom
Tioit-Wang:feat/proactive-subagents

Conversation

@Tioit-Wang

Copy link
Copy Markdown
Collaborator

What

Makes subagent delegation a proactive, first-class orchestration capability instead of a rarely-used context-saving tool. The main agent is taught when to delegate (system prompt triggers), can keep working while delegates run (non-blocking Task), and gets a full lifecycle vocabulary to converge on demand.

This is the PI-Desktop side of a comparison against Proma's collaboration design (same Pi runtime under the hood) — the key gaps were prompt engineering (no positive trigger patterns, defensive tool description) and blocking semantics (Task awaited the delegate, so the parent could never work in parallel).

Changes

  • Task is now non-blocking: starts a subagent in the background and returns a delegationId immediately. New Agent-mode core tools drive the lifecycle (ADR 0089):
    • TaskWait(delegationIds?, mode?, minCompleted?, timeoutSeconds?) — converge on running delegations (mode: "any" for early convergence; settled delegations re-readable by id)
    • TaskList() / TaskStop(delegationIds?) — inspect / stop
    • Per-session delegation registry; delegates still running at run end, on parent abort, or on dispose are stopped
  • Proactive prompt engineering:
    • New ## Delegation system-prompt section with positive trigger patterns: parallel exploration, adversarial review, multi-file implementation, context-economy searches, batch sharding
    • Task tool description rewritten to lead with those triggers
  • New builtins:
    • explorer rewritten in the omo-slim style (tool-choice guidance, parallel searches, <files>/<answer> report shape)
    • fixer — write-capable implementation specialist (Read/Glob/Grep/Edit/Write/Bash, maxTurns: 40, <summary>/<changes>/<verification> report)
  • Per-definition permission scope (frontmatter permission: inherit | ask | accept-edits | auto): the sidecar attaches the scope to the delegate's tools.execute calls and host-core resolves them under that mode instead of the session's mode. The contract modes' hard deny and the external-path gate stay in force. fixer ships with accept-edits — writes inside the workspace without prompting, Bash and external paths keep the session's behavior.
  • Concurrency: MAX_SUBAGENT_CONCURRENCY becomes a per-session running cap of 10 (was 4 per batch); Task fails with a tool error when the cap is reached.
  • UI: TaskWait/TaskList/TaskStop share the delegation presentation but are excluded from the topology's subagent counts; stopped outcome recognized and localized (en/zh-CN).

Validation

  • pnpm -r --if-present typecheck — all packages pass
  • pnpm -r --if-present lint — pass
  • @pi-desktop/shared — 246 tests pass
  • @pi-desktop/agent-runtime — 200 tests pass (new lifecycle suite: background start, TaskWait convergence all/any, cap enforcement, turn-end abort, permission-scope wiring)
  • @pi-desktop/desktop — 651 pass, 1 fail: plugin-fs-scope.test.mjs fails only on Windows (p.endsWith("out/report.md") against backslash paths) — byte-identical to upstream/main and untouched by this branch (upstream CI runs Linux)
  • host-core — 252 pass incl. new delegate-scope RPC test; 4 failures are pre-existing Windows-only tests (path separators, PowerShell lacks seq) — all in tools::tests, untouched by this branch
  • Docs site builds clean (vitepress build)

Docs

  • ADR 0089 (renumbered after upstream's 0087/0088 landed), D228 in the decisions log, E2E-142 in the test plan (renumbered after upstream's E2E-130), zh-CN mirrors updated.

Commits

  1. feat(shared): permission scope on subagent definitions, cap 10
  2. feat(agent-runtime): background delegation behind TaskWait lifecycle (+ prompt triggers)
  3. feat(agent-runtime): omo-slim-style explorer + write-capable fixer
  4. feat(host-core): per-definition permission scope on tools.execute
  5. feat(desktop): lifecycle tool presentation + stopped status (en/zh-CN)
  6. docs: ADR 0089, D228, E2E-142 (+ zh-CN mirrors)

…t lifecycle

Task starts a subagent and returns immediately with a delegation id; the
parent keeps working and converges with TaskWait (all/any/minCompleted),
inspects with TaskList, and stops with TaskStop. The runtime owns a
per-session delegation registry and aborts leftover delegates at run end,
on parent abort, or on dispose. The base prompt gains a Delegation section
naming positive trigger patterns, and the Task description leads with them.
…ble fixer builtin

explorer is rewritten in the omo-slim style (Grep for patterns, Glob for
discovery, parallel searches, <files>/<answer> report shape). A fourth
builtin, fixer, implements multi-file changes from a complete spec with
Read/Glob/Grep/Edit/Write/Bash under permission: accept-edits.
…ermission scope

ToolsExecuteParams gains an optional permissionScope; the permission
resolver uses it instead of the session's effective mode for that call.
The contract modes' hard deny and the external-path gate stay in force,
so accept-edits auto-allows in-workspace Write/Edit while Bash and
external paths keep the session's behavior.
… status

TaskWait/TaskList/TaskStop share the delegation presentation but are not
delegation activity items, so the topology card's subagent counts stay
accurate. The stopped outcome is recognized and localized in en and zh-CN.
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

@Tioit-Wang is attempting to deploy a commit to the vastsa's projects Team on Vercel.

A member of the Team first needs to authorize it.

…, E2E-142)

Spec §5f/§5f.1 (agent runtime) and §10.2 (tools and permissions) describe
the non-blocking lifecycle, the permission scope and the new builtins; the
decisions log and the E2E plan gain D228 and E2E-142; zh-CN mirrors follow.
@Tioit-Wang
Tioit-Wang force-pushed the feat/proactive-subagents branch from 8f972cd to 1dae48c Compare August 14, 2026 21:11
@vastsa
vastsa merged commit bd00cb5 into vastsa:main Aug 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants