Repository navigation
improve(advisor): steer agents back on course with a much simpler plugin - #174568
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesSimplifies Advisor to one background review that steers an active run, removing verification and next-turn fallback delivery. Example: Advisor reviews after three repeated failures caused by a misspelled configuration key.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR is ready for normal landing review: the previous dispatch-time finding is fixed, current-head CI is green, and no additional actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAdvisor is an optional bundled plugin that consumes user-run lifecycle and tool-completion events, forks the session for a tool-free review, and sends guidance through the existing guarded steering API. flowchart TD
A[User run] --> B[Lifecycle and tool events]
B --> C[Advisor settlement and triggers]
C --> D[Service scheduled session fork]
D --> E[Review decision]
E --> F[Guarded active run steering]
F --> A
Technical reviewBest possible solution: Land the single-pass Advisor implementation with its settlement checks, cancellation, existing permission enforcement, and updated documentation. Do we have a high-confidence way to reproduce the issue? This is an existing feature's behavior redesign; supplied live Gateway evidence demonstrates the intervention scenario, while source and the new regression establish the previous dispatch finding's repair. Is this the best way to solve the issue? The simpler implementation uses existing fork, scheduler, event, and guarded steering owners, removes the superseded controller and verifier, and explains its intervention-quality tradeoff. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bb55f0c90e5f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -348, Tests -697, Docs -96, Generated 0. Total -1141 across 10 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed October 17, 2026, 1:54 AM ET / 05:54 UTC (Revision 9). |
e63ffdb to
c671c4f
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
1642e8a to
49b3ca9
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 22dd373. Advisor is now one review that steers the active run when the agent goes off course: no verifier, no follow-up turns, no hidden next-turn notes, so advice always stays inside the requester's own run and permissions. Reviews fork only after running tool calls (including Codex native and Code Mode calls) report real results. Proof: live mid-run steers on the Codex and built-in runtimes, the prompt-injection refusal trace, Codex Code Mode timing traces, and the focused suite (12 tests, each new case failing without its fix). |
…gin (openclaw#174568) ## What Problem This Solves Advisor almost never interjects when an agent goes off course. Corrections waited until every tool call settled, then passed through a second verifier fork, and the verifier rejected most real corrections, so in practice the agent kept looping, polling or drifting without hearing anything. ## User Impact With Advisor enabled, an agent that repeats a failing step, polls finished work, works around a blocker it could fix, or drifts beyond the request gets one short correction in its active run, before its next step. Advisor stays off by default and its config keys are unchanged. ## Why This Change Was Made Advisor is now one review and one steer, using primitives core already has: - Count tool calls in user-triggered runs. When `everyToolCalls` or `everyMinutes` is due, fork the session (`forkSession`) and ask whether the agent is on track. - On `CORRECTION`, steer the active run (`steerActiveRun`). The advice joins the requester's own run, so its permissions and sender restrictions still apply. If the run already ended, or steering is refused (for example `hooks.allowPromptInjection=false`), nothing is delivered. The run ending also cancels a review still in flight. - The plugin reference now documents the single-pass review. - A due review forks only once every running tool call has its real result (Codex native tools: their item completion; outer Code Mode calls: their recorded output; a raw call and a native child that share an ID settle separately). The original dispatch-time recheck is kept: a review queued before another call starts stands down and stays due until that call's result, because a live unfinished-call fork once produced synthetic aborted results and false retry advice., because Codex fills a missing output with a synthetic `aborted` result in forks. - Removed: the verifier stage, the old settlement bookkeeping, Codex item bookkeeping, the next-turn injection fallback and the reply parser's word and token rules. The model decides; code only reads the `NO_CHANGE`/`CORRECTION` shape. - The default instructions say plainly what "off course" means. The plugin drops from about 1,600 to about 420 lines including tests (+339/−1617 overall). ## Evidence - Focused tests: `pnpm vitest run extensions/advisor` (12 passed; the outer-call, shared-ID receipt and dispatch-recheck cases each fail without their fix) and `src/plugins/contracts/boundary-invariants.test.ts` (12 passed). `ui:i18n:verify` and the config-doc baseline check pass. - Live, isolated Gateway, `openai/gpt-6.1-sol` on the Codex harness, Advisor at `everyToolCalls: 3`. Task: poll a check script whose config has a typo. Rows 18–20: the third identical failure. Row 21: the Advisor steer, stored after the tool result with `sourceTool: plugin:advisor`. Row 22: the agent switches from re-running to inspecting the config, fixes the key, and reports READY. Gateway log: `advisor: steered active run`. - Built-in OpenClaw runtime (`agentRuntime.id: "openclaw"`), same setup with the Control UI: reviews fork with a warm cache (17–25k cached input tokens, 75 uncached), and corrections are stored between tool calls while the run keeps going. - Steer-only head, built-in runtime, test-only `reviewInstructions` that force a correction: the steer is stored at row 26 directly after a tool result (`sourceTool: plugin:advisor`), the run continues at row 28, and the log shows `advisor: steered active run`. No other turn is started. - Codex harness, three 15-second commands in a row with `everyToolCalls: 1`: each review forked within 1 ms of the command's `commandExecution` item completing (10:00:51.3, 10:01:08.1) and never while a command was running. - Codex Code Mode, one outer call that runs a command, waits 15 seconds, then runs another (`everyToolCalls: 1`): the child command finished at 10:21:48.3 while the outer call stayed open; the review forked only after the outer call recorded its output at 10:22:06.5. - Permission boundary, isolated Gateway: with `hooks.allowPromptInjection=false` and test-only `reviewInstructions` that force a correction, every correction logged `correction not delivered (blocked by plugins.entries.advisor.hooks.allowPromptInjection=false)`. - Replay of a real 4-hour coding session (62 review points at the default 10-tool-call trigger, real transcript history): Advisor proposed the same course change the user later asked for about 20 minutes earlier in two of four user interventions ("stop debugging unrelated Gateway startup and implement the fix"; "stop expanding the evidence bundle"). Labs description on this branch:  **Merge danger:** two-way door. A revert restores the previous plugin entirely; nothing migrates and no state is written. Blast radius is limited to users who turned on the Advisor lab: their agents can receive one short steered correction per review while a run is active. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Advisor almost never interjects when an agent goes off course. Corrections waited until every tool call settled, then passed through a second verifier fork, and the verifier rejected most real corrections, so in practice the agent kept looping, polling or drifting without hearing anything.
User Impact
With Advisor enabled, an agent that repeats a failing step, polls finished work, works around a blocker it could fix, or drifts beyond the request gets one short correction in its active run, before its next step. Advisor stays off by default and its config keys are unchanged.
Why This Change Was Made
Advisor is now one review and one steer, using primitives core already has:
everyToolCallsoreveryMinutesis due, fork the session (forkSession) and ask whether the agent is on track.CORRECTION, steer the active run (steerActiveRun). The advice joins the requester's own run, so its permissions and sender restrictions still apply. If the run already ended, or steering is refused (for examplehooks.allowPromptInjection=false), nothing is delivered. The run ending also cancels a review still in flight.abortedresult in forks.NO_CHANGE/CORRECTIONshape.The plugin drops from about 1,600 to about 420 lines including tests (+339/−1617 overall).
Evidence
pnpm vitest run extensions/advisor(12 passed; the outer-call, shared-ID receipt and dispatch-recheck cases each fail without their fix) andsrc/plugins/contracts/boundary-invariants.test.ts(12 passed).ui:i18n:verifyand the config-doc baseline check pass.openai/gpt-6.1-solon the Codex harness, Advisor ateveryToolCalls: 3. Task: poll a check script whose config has a typo. Rows 18–20: the third identical failure. Row 21: the Advisor steer, stored after the tool result withsourceTool: plugin:advisor. Row 22: the agent switches from re-running to inspecting the config, fixes the key, and reports READY. Gateway log:advisor: steered active run.agentRuntime.id: "openclaw"), same setup with the Control UI: reviews fork with a warm cache (17–25k cached input tokens, 75 uncached), and corrections are stored between tool calls while the run keeps going.reviewInstructionsthat force a correction: the steer is stored at row 26 directly after a tool result (sourceTool: plugin:advisor), the run continues at row 28, and the log showsadvisor: steered active run. No other turn is started.everyToolCalls: 1: each review forked within 1 ms of the command'scommandExecutionitem completing (10:00:51.3, 10:01:08.1) and never while a command was running.everyToolCalls: 1): the child command finished at 10:21:48.3 while the outer call stayed open; the review forked only after the outer call recorded its output at 10:22:06.5.hooks.allowPromptInjection=falseand test-onlyreviewInstructionsthat force a correction, every correction loggedcorrection not delivered (blocked by plugins.entries.advisor.hooks.allowPromptInjection=false).Labs description on this branch:
Merge danger: two-way door. A revert restores the previous plugin entirely; nothing migrates and no state is written. Blast radius is limited to users who turned on the Advisor lab: their agents can receive one short steered correction per review while a run is active.