Repository navigation
Conversation
A plugin fork reads its requester from the latest user-role row. When a subagent had just finished, that row was the completion report, which records no owner, so an owner's fork with exec (Better) was refused until the owner sent another message. The Gateway now marks a completion report it delivered itself (__openclaw.hostCompletion), set only for backend callers on the host's own write path. Agent params cannot carry it, and a write hook can neither add nor keep it. The fork skips only marked reports, the same way it skips steering rows, and takes the requester of the input before them. A marked report that names a different sender is not skipped. Reports sent through the agent method by a client stay that client's input. Rows from before this change have no marker and behave as before.
|
🦞👀 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: passed. What this changesThe PR marks host-delivered completion reports so plugin forks retain the preceding input's requester. Example: An owner starts a subagent, waits for its completion report, then invokes Better 0.1.1 without sending another message.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current requester-selection bug without weakening the existing exec checks; the earlier fixture finding is resolved, and no blocking defects remain. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway records user-turn metadata; the session-fork reader selects requester facts that the existing fork admission owner uses to check tools and authenticated callers. flowchart TD
A[Host completion delivery] --> B[Gateway user turn writer]
B --> C[Transcript metadata]
D[Plugin helper request] --> E[Session fork reader]
C --> E
E --> F[Existing tool and caller checks]
F --> G[Hidden fork execution]
Technical reviewBest possible solution: Keep requester selection in the existing fork reader, preserve host-only completion marking, and retain the current admission checks and historical-row behavior. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the refusal path, and the contributor's terminal evidence demonstrates it before the fix; no target code was executed during this read-only review. Is this the best way to solve the issue? The repair uses the existing transcript writer and fork reader, distinguishes host delivery from caller-supplied provenance, and preserves the established owner and caller restrictions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2f35a255adec. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +45, Tests +221, Docs +4. Total +270 across 10 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label 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 (1 earlier review cycle)
Reviewed November 26, 2026, 5:30 PM ET / 22:30 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Closes #206173
What Problem This Solves
Plugin helpers that fork a chat with
execstop working right after a subagent finishes in that chat. Better (obviyus/openclaw-better-prompt) is one of them: the owner clicks Better in a chat where a subagent just reported back, and gets "This chat's tool policy does not allow read, ls and exec, so the helper cannot read your files." The click only works again after the owner sends a throwaway message. Chats that use subagents, such as Goal chats, hit this most.User Impact
exec. A signed-in caller still needs to be the person who sent the turn, as fix(plugins): run session-scoped plugin forks in the admitted session #204411 set.Why This Change Was Made
A plugin fork checks tool policy as the requester of the turn it reads through, and takes that requester from the latest user-role row. A subagent's completion report is a user-role row, but it records no owner: it delivers the result of work an earlier turn started. So the fork judged the owner's click by the report instead of by the owner's turn.
The fork already skips steering rows for the same reason (a steer joins the running turn). It now also skips completion reports, but only the ones the Gateway delivered itself:
subagent_settle,subagent_announce, or an agent-mediated completion), the Gateway records__openclaw.hostCompletion: trueon the row. It sets this only on its own write path, for backend callers (the samecanUseInternalRuntimeHandoffcheck that already guards other internal handoff controls).agent; upstream accepts that on purpose. Its row carries no marker, so it stays that client's own input.agentparams cannot carry the marker (the agent and provenance schemas are closed), and abefore_message_writehook can neither add the marker nor keep a forged one.Decisions
read/lspolicy and the run's requester stay consistent.readSessionForkTurn.agentmethod accepts completion provenance from anyoperator.writeclient, and a client without a signed-in identity records no sender. Without the marker, such a row would borrow the owner's earlier turn.hostCompletioncheck in the reader.agent.events-and-subagentsasserts a public caller may sendsubagent_announceprovenance and is recorded as non-owner. The marker leaves that behavior alone.agent-request-preflight.tsinstead.execon the signed-in caller's own authorityexecon another owner's turn through asessionAccessmethod. #205483 removed a second owner producer so one turn gives one owner answer.Evidence
Real-model proof, before and after. A throwaway Gateway on a Mac with its own
HOMEandOPENCLAW_STATE_DIR, Better 0.1.1 installed from its published package, and a real model:anthropic/claude-haiku-4-5on theclaude-cliruntime with a Claude Code setup token, the routing a Claude subscription install uses. Tool profilecoding. The owner asks the agent to callsessions_spawn; the model does, the child runs on the same model and finishes, and the Gateway delivers its completion report into the chat. Then the owner clicks Better with no new message, asking the helper to runsh probe.sh, which writes a marker file whenexecruns. Rows are read from the stored transcript.Base
36395007cf0b:Head (this PR):
Both report kinds (
subagent_settlefrom a yield wake,subagent_announcefrom a direct completion) are completion reports, and the real in-process delivery wrote the marker on head. The setup token was passed on stdin only; a scan of each run directory found it in 0 files.Upgrade from the latest stable release (2026.11.10, npm). One state directory, first run on the published 2026.11.10 build, then on this PR's build:
The transcript, sessions and settings load after the migration. The published 2026.11.10 build refuses Better's core tools entirely (it predates core tools in plugin forks), so the stable side has no "before" for this bug. Its completion report was stored as a steer into the owner's running turn (
steerTargetRunIdon the row), which the fork already skipped before this change, so that old row behaves as before.Old unmarked report as its own turn (the known limit). The base build's state from the first run, upgraded to this PR's build:
The old unmarked report is refused exactly as before; the next report the Gateway delivers is marked, and the fork is admitted with
read,lsandexec. Here the model rewrote the request instead of runningprobe.sh, so no marker file; the admission itself is the change (base and the old row return the refusal above before any model call).Regression tests.
gateway-plugin-forked-turn-session-tools.e2e.test.ts(real Gateway, scripted model): a report written throughagentby a local backend Gateway client (the host's delivery path) is skipped, and the owner's fork runsexec. An ordinary client'sagentcall withhostCompletionin its params, or insideinputProvenance, is rejected as invalid params. The same client's report without the marker stays its own input, andexecis refused before any model call. A host report after a non-owner channel turn is still refused. A signed-in caller's own report through asessionAccessmethod is refused.session-manager-model-context-limits.test.ts: the reader skips a marked report, keeps an unmarked report (subagent or media) as its own input, keeps a marked report that names another sender, and falls back to a lone report's own facts.user-turn-transcript.persistence.test.ts: the marker survives a write hook that clears metadata, a hook cannot add it to an unmarked report, and it is never written on an input that is not a completion report.gateway-plugin-forked-turn.e2e.test.ts: a chat whose only input is a completion report still forks.Red (the source fix reverted with
git apply -R, new tests kept): the host-report e2e case, the reader unit test and the write-hook test fail.Mutations, each removing one guard:
exec), and the reader unit test fails;Green on head: e2e 10 of 10, unit and consumer tests all pass.
Consumers of the changed reader and user-turn writer:
session-fork-run.test.ts,prompt-cache-keep-warm.test.ts,input-provenance.test.ts,user-turn-transcript.test.ts,agent-run-user-turn.test.tsand theagenthandler tests pass.Not covered. The Control UI button itself was not clicked in a browser; the click goes through the same
plugins.sessionActionmethod the button calls. The e2e host path is a local backend Gateway client, not the in-process announce dispatch; the real-model runs cover the in-process path with a real child. An earlier run of the same flow with a loopback mock model gave the same before and after.🦞 Made with OpenClaw