@henryqw/pi-advisor

Opt-in second-model review of each Pi agent run after it settles, with graded notes and one blocker follow-up.

Packages

Package details

extension

Install @henryqw/pi-advisor from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@henryqw/pi-advisor
Package
@henryqw/pi-advisor
Version
0.3.1
Published
Nov 6, 2026
Downloads
585/mo · 158/wk
Author
henrywang
License
MIT
Types
extension
Size
30.9 KB
Dependencies
1 dependency · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./extensions/advisor.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@henryqw/pi-advisor

Let a second model examine the tool calls and results of each agent run after Pi settles the run. The advisor returns graded notes. A blocker sends one follow-up message that makes the agent fix it.

Install

pi install npm:@henryqw/pi-advisor

Requires Pi 1.5.0 or later in the 1.x series.

The advisor uses the pi-advisor/review Model Task. Its default Task Profile is balanced. Run /task-models to configure a route for that profile before you turn the advisor on.

Works with

Package Relationship Purpose
@henryqw/pi-goal Improves Goal continuations stay in one run. The advisor examines all of that work after the run settles.
@henryqw/pi-task-models Required Provides the advisor model route.

Use

Type /advisor to see filtered, described choices for on, off, and status.

Run /advisor on. Then send a prompt that makes the agent use tools. When the run settles, the advisor examines it in the background, and Pi shows the result.

Surface Type Purpose
/advisor on command Turn the advisor on for this conversation branch.
/advisor off command Turn the advisor off for this conversation branch.
/advisor status command Show whether the advisor is on for this conversation branch.
Advisor reviewing… ui Footer status while the review runs.

The advisor is off by default.

Results

Reply What Pi shows Continuation
PASS The Advisor: PASS notice. No
Only nit notes One notice with all notes. No
A concern note One warning with all notes. No
A blocker note One warning with all notes. One follow-up for each user prompt
Malformed reply, or a reply longer than 8,000 characters One warning, one time in each session. No

Flow

flowchart TD
    accTitle: Pi Advisor review flow
    accDescr: A user prompt or triggering custom message starts a run. Other extensions can continue that same run before it settles. Review needs the advisor on for the branch, a user interface, a recorded run start, tool calls, and a completed run without abort. The background review gets only the latest user prompt and bounded run record, with no tools. No route means no session-model fallback. A blocker starts a new run only when the editor is empty and no blocker follow-up was sent since the latest user prompt. Cancelled or stale replies are ignored.
    Run["Agent run"] --> Settle["Run settles"]
    Run -->|Other extension continues| Run
    Settle --> Gates{"All review conditions met?"}
    Gates -->|No| End["No new turn"]
    Gates -->|Yes| Route{"Review route available?"}
    Route -->|No| Missing["Warn; no session-model fallback"]
    Missing --> End
    Route -->|Yes| Review["Background review; no tools; 90 seconds"]
    Review -->|Cancelled or stale| End
    Review -->|Timeout or model error| Warning["Show warning"]
    Warning --> End
    Review -->|Reply| Valid{"Valid reply within 8,000 characters?"}
    Valid -->|No| Malformed["Warn once per session"]
    Malformed --> End
    Valid -->|Yes| Notes["Show PASS or graded notes"]
    Notes --> Blocker{"Blocker, empty editor, follow-up unused?"}
    Blocker -->|No| End
    Blocker -->|Yes| FollowUp["Visible blocker follow-up; once per prompt"]
    FollowUp --> Run

Read the static advisor flow diagram on npm or without a Mermaid renderer.

  1. A user prompt or a triggering custom message starts a run. Pi Advisor records where the run starts on the branch.
  2. Other extensions can continue the run. All of their turns stay in the same run.
  3. Pi settles the run. Pi Advisor does no review for a run without tool calls, an unfinished run, or a session without UI.
  4. Pi Advisor sends one tool-free request to the advisor model in the background. The request contains the latest user prompt and the run record.
  5. Pi shows the notes. For a blocker note when the editor is empty, Pi Advisor sends a visible pi-advisor-blocker follow-up message. The message starts a new run that fixes the blockers.
  6. The advisor also examines that new run. It shows the notes, but it sends no other follow-up until the next user prompt.

State and storage

Pi Advisor keeps no files. /advisor on and /advisor off append a pi-advisor custom entry to the conversation. The latest entry on the current branch sets the state, so branch navigation, /tree, forks, and rewinds show the state of the selected branch.

Each blocker follow-up is a visible pi-advisor-blocker message on the branch. Its details contain the notes.

Limits and recovery

Limit Behavior Recovery
Interactive only The advisor does not run in print mode or other modes without UI. Examine the run manually.
No route Pi shows a warning that names /task-models. The advisor does not use the session model. Run /task-models and set a route for the pi-advisor/review profile.
Time limit The review stops after 90 seconds and Pi shows a warning. Pi shows no notes. Send the next prompt.
Cancel A new prompt, a new run, branch navigation, /advisor off, or session exit cancels the review. Pi shows no notice. Escape in an idle session does not cancel it. Send a prompt to cancel the review.
Old reply When the branch changes or Pi starts work before the reply arrives, Pi Advisor ignores the reply. Send a prompt to start a new run.
Model error Pi shows a warning. Pi shows no notes. Run /task-models to examine the route, or send the next prompt.
Run record size Each item is truncated to 4,000 characters, and the prompt to 8,000. The record keeps the newest 48,000 characters and marks earlier items as omitted. Ask for a smaller run when early steps must be examined.
One follow-up A blocker sends one follow-up message for each user prompt. Send a prompt to fix the remaining blockers.
Draft in the editor When the editor contains text, a blocker sends no follow-up message. Pi shows all notes and tells you to send a prompt. Send a prompt to fix the blockers.
Advice only The advisor sees only the run record. Its notes can be wrong. Examine each note before you accept it.