Repository navigation
fix(agents): keep agent_end preparation within the turn lifetime - #197947
ericcaiwx-star wants to merge 2 commits into
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 real behavior proof before merge. What this changesThis PR awaits terminal-message hydration before releasing the turn scope, while leaving plugin agent_end handlers in the background. Example: An embedded turn runs tool_search, dispatch_action, and session_status before completing.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR: it addresses a current lifecycle defect with a focused repair in the existing owner. No definite introduced bug was found; the PR remains a draft. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe agent-end harness receives completed-turn facts and a deferred transcript loader, prepares plugin hook input, and dispatches handlers within the turn's plugin invocation lifetime. flowchart TD
A[Embedded turn completes] --> B[Prepare completed turn anchor]
B --> C[Hydrate terminal messages]
C --> D[Admit plugin handlers]
D --> E[Release turn scope]
D --> F[Background handlers finish]
Technical reviewBest possible solution: Keep terminal hydration within the existing awaited preparation owner and dispatch handlers before releasing the turn scope. Do we have a high-confidence way to reproduce the issue? Current source exposes the delayed-hydration admission gap, matching the supplied named-base Gateway failure; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch repairs the owning lifetime boundary with no new state or API and preserves subscriber filtering, best-effort errors, and background handler execution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d30e45c3f48e. Provenance checked
TestingProof path: none. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +15, Tests +105. Total +120 across 3 files. Added test files: 1. 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. 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 Reviewed November 12, 2026, 6:23 PM ET / 23:23 UTC. |
Closed in favor of #197990, opened by the issue author for the same fix. No merge or author-delivery completion is claimed for this Draft.
Related: #197940
What Problem This Solves
After an embedded turn calls
dispatch_action, deferred terminal-message hydration can outlive the plugin invocation scope. The reply succeeds, but pluginagent_endhandlers fail before executing.User Impact
The candidate hydrates terminal messages within the awaited turn preparation owner, then starts handlers without waiting for their completion. Existing admission checks, no-subscriber behavior and best-effort failure handling remain intact.
Why This Change Was Made
Implementation head:
3e27ee9c18fd0dde03f0fb5539292df5583c0056. The repair stays inrunAgentEndSideEffectsAsync. This Draft is being closed because the issue author is carrying the same repair in #197990.Evidence
Actual named-base failure and exact-head post-fix proof were executed through
ocpr prove:4efd662cc2c6f9f2afa8330ac813e48c9bd9b0a2: built isolated Gateway, existing local Ollamaqwen3.6:35b-a3b, and two real plugin registrations. The chat-completions request returned HTTP 200 aftertool_search→dispatch_action→session_status; neither terminal handler executed, and both loggedPlugin invocation scope is closed. Required-hook assertion exited 1.3e27ee9c18fd0dde03f0fb5539292df5583c0056: the same shipped entry executed both terminal handlers exactly once, each receiving 8 messages, with zero closed-scope errors. A fresh direct-tool control executed both once with 5 messages. Both task-owned Gateways were terminated and joined. The formal post command exited 0.PluginInstance/PluginInvocationScoperegression: baseline failed with zero handler entries; candidate passed. Pending handlers do not block foreground completion. No-subscriber and rejected-hydration controls passed.qaRuntimebuild passed. Independent local P0–P2 review reported no actionable findings.Executed runtime driver commands (each starts the built Gateway using
pnpm openclaw gateway run):AI-assisted.