Repository navigation
fix(channels): claim ask_user replies before turn admission - #146847
ericcaiwx-star wants to merge 5 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 changes before merge. What this changesThis PR lets eligible channel replies settle pending agent questions before admitting another turn while preserving command priority and answer custody. Example: An external channel dispatches “没事” while its agent is waiting on ask_user.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this PR contains meaningful, proven channel-answer handling that has not been established as superseded. No introduced actionable defect was found, but confirmed conflicts and unresolved CI attribution prevent landing. Priority: P1 Before merge
FindingsNone. Agent review detailsHow this fits togetherChannel plugins submit inbound messages to core dispatch, which selects commands, pending-question answers, or ordinary turns; the question owner validates authority and commits resolution through the Gateway. flowchart TD
A[Channel plugin] --> B[Core inbound dispatch]
B --> C[Control commands]
B --> D[Active execution owner]
D --> E[Pending question owner]
E --> F[Gateway authorization and resolution]
B --> G[Ordinary turn admission]
Technical reviewBest possible solution: Integrate the still-needed early-answer behavior with main’s session controller and asynchronous authority readers under one input-custody owner. Do we have a high-confidence way to reproduce the issue? The pinned base places reply-operation admission before question handling, and the published candidate run exercises the repaired public dispatcher; no fresh reproduction against main’s later controller architecture was executed. Is this the best way to solve the issue? The pinned implementation preserves existing execution, question, and binding owners, but integration must retain main’s newer controller custody and asynchronous policy preparation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d1cdb8b69707. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +692, Tests +3021, Docs +91. Total +3804 across 40 files. Added test files: 6. 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. Review metrics
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 (35 earlier review cycles; latest 8 shown)
Reviewed November 15, 2026, 2:05 AM ET / 07:05 UTC (Revision 36). |
b820a50 to
eb92c3e
Compare
eb92c3e to
eb20c20
Compare
|
@clawsweeper re-review Rewritten at |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Exact head: This revision removes the process-local 1,024-entry binding publication/LRU and moves the final source-binding check to the Gateway Separate-writer proof: a second Exact-head validation: 78 focused tests passed; |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Exact head: The prior review found no actionable or security findings and marked proof sufficient. This follow-up is CI-only: refresh the generated Swift model for the optional Final-head evidence: 86/86 focused regressions passed; the minimized guard/transport subset passed 24/24; |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Rebased exact head: The rebase had one conflict in the CI-only follow-up because current main now exports the same run-projection merge helper; the upstream implementation was kept. Rebased-head validation passed: 88/88 focused regressions, full protocol check against the exact upstream base, |
|
🦞👀 Re-review progress:
|
|
Maintainer handoff for exact head ClawSweeper reports no actionable or security findings, proof is sufficient, and the PR is labeled The aggregate CI run is red for two non-Gateway rows:
The author account cannot rerun upstream Actions jobs ( |
|
@clawsweeper re-review Refreshed exact head |
|
🦞👀 Re-review progress:
|
Related: WecomTeam/wecom-openclaw-plugin#187
What Problem This Solves
Fixes plain-text answers becoming a new agent turn when an external channel uses the public inbound dispatcher while an
ask_userquestion is pending.User Impact
An eligible human reply resolves the original pending question before a successor turn is admitted. Control and registered plugin commands keep priority; media, non-human events, and messages with no pending question keep their existing paths.
The optional, bounded
sourceBindingRoutesfield belongs only to the existingquestion.resolverequest (answer and cancel forms). Stored question/session formats and responses are unchanged, so this needs no data migration or operator action.Why This Change Was Made
The inbound admission path now asks the existing runtime question owner to claim the answer, retaining the current execution owner's profile admission and frozen tool authority. It carries the prepared conversation route through queued handoff and checks current source/creator authority after awaited preparation and at the Gateway commit boundary. The durable binding check uses the existing ordered SQLite worker owner.
Pending fallback answers retain the existing route-only authority proof through the actual host claim and record the same prepared participant identity admitted by the current profile owner. An invalid multi-question answer keeps the question open and emits the existing suppression-safe retry notice through both early and later dispatch.
Confirmed, refused, and indeterminate answers retain their recorded custody and cannot be replayed as a new user turn. An explicitly unsupported legacy dispatcher before I/O reasserts current source/binding authority and continues ordinary dispatch. A source-bound V1 execution backend remains unsupported under the existing owner contract; it gains no host-claim bypass. Question-only runtimes with no execution target remain covered.
Evidence
Candidate head:
fd9cd3f94d14b703315d4a635d96026779430237Tree:
a10e67a6911cc75d96e50c17a46e4ee69724d94fBase:
bb5656bf89e230bb3d6c9040b1e9b86df0306439The refresh resolves the new conflict with current main's physical-source preparation callback. Both ordered and unordered readers retain
prepareSourcebefore reading and the existing asynchronousbeforeConsumepreparation before synchronous consumption; currentness is reasserted after the awaited preparation. The current-main line-cap growth ratchet also required moving the existing read-scope capture/native-selection pair into one sibling owner with direct internal imports. Both function bodies are unchanged; their consuming-frame authority checks stay in place. No additional schema, configuration, stored format, public SDK API, or changelog change was introduced by this refresh.check:changedrun passed on this exact head (1672.23 seconds): all 42 selected stages, including current line/max-line/SAFETY/SQLite/mock/timeout ratchets, format and docs, plugin boundaries, core/extension production and test types, all 27 core test graphs and four root test graphs, three dead-export scans (zero entries), whole core/extension/script/root lint, native schema and database/media/sidecar/cycle/auth guards. Runtime import cycles are zero. Ten untouched-main max-line warnings and the existing temp-creation cleanup warning are nonfatal. The initial draft failed the new line-cap growth gate; the coherent helper relocation resolved it and this complete final run passed. Head, source diff identity and lock SHA/mtime/ctime remained unchanged.PROTOCOL_SINCE_BASE_SHApinned to the stated base. Tracked source and lock identity remained unchanged; the current-main deletion of the old tracked Swift generated file is preserved.api.runtime.channel.inbound.dispatchadopted the plain-text answer into the original pendingask_userturn, produced its originating final reply, and created zero successor agent turns./stopstayed on core dispatch and delivered the abort reply without becoming a question answer. The fixture used isolated mock provider/state, not a real external tenant. Both fresh canonical build/runtime stamps identify this head with clean inputs; completed compiler-generation verification, tracked source and lock SHA/mtime/ctime checks passed without a freshness override.Candidate-specific CI and review handoff
The refreshed head
fd9cd3f94d14b703315d4a635d96026779430237completed CI run 37214288661 with 92 successful jobs, 15 skipped jobs and three failed jobs. The actual tested merge wasf4182df89ad4f252c01e6416f296228c07c7d060(tree0f131e30d0f267206492342349dfedf4b89a7d3e), with parents main704a21dd91ef8f645bfea0fd24ec4652515b45b9and this candidate. All platform tails completed; the aggregate CI gate mirrors the two actual failed jobs.UI E2E shard 1/4 failed the two 1280px/390px model-picker cases at
chat-composer-catalog.e2e.test.ts:153:aria-busywas false instead of true while a mock Gatewaychat.sendresponse was deferred. The failing test, suite, mock Gateway/controls, picker and cleanup blobs match the actual main parent and are outside this PR. A separate PR's CI on the same main parent shows the same assertion. The runtime cause is unconfirmed; this source comparison does not waive red CI.The changed Node aggregate failed only Gateway SIGKILL/restart recovery, waiting 120 seconds at
gateway-kill-restart-send.e2e.test.ts:123for a restart dispatch marker and transcript advance. The final bus contained only the initial inbound message; cold route refusal was followed by background database recovery, without the expected restart dispatch marker. Fourteen selected unowned test/recovery/startup/turn/mock-input owners match current main and the retained historical Linux control/candidate pair. The owned mock assistant tool-result adapter matches its historical candidate blob. The earlier Linux pair supplies a similar failure signature, but current main704a21dd...was not replayed, and no single cause or baseline waiver is claimed. No unrelated recovery code was changed.The same actual CI aggregate passed public-plugin
ask_useracceptance in 13.218 seconds: the answer was adopted before resolution, resumed the originating run, produced its final reply and created zero successor turns;/stopremained on core dispatch and delivered its abort reply. This is fresh evidence for the tested merge above.ClawSweeper revision 33 reviewed the exact refreshed head: no introduced actionable code/security findings and sufficient terminal production-path proof (5/6). It verified the current-main
prepareSourceplus PRbeforeConsumecomposition. Its automatic before-merge migration checkbox remains despite the same report explicitly resolving that warning and confirming no stored-data contract change. This contradiction and the red CI landing decision remain for maintainers; no bot-managed labels or migration behavior were altered.Regression and compatibility details
The real queued source regression failed before repair when the prepared route was dropped and when a reassigned binding still reached question resolution. Current tests prove matching routes survive handoff; local reassignment and final Gateway
QUESTION_SOURCE_BINDING_CHANGEDrefuse without replay, successor admission, or follow-up queue entries. The paired early-dispatch regression uses an actual legacy function dispatcher that reports Unsupported before registration/I/O: ordinary dispatch was blocked before repair and now proceeds without consuming the pending question; an actual refusal still stops admission.Gateway proof also covers an ignored cron binding, a separate SQLite writer deleting an active binding, refusal leaving the question pending, and an authorized replacement retry resolving that question. The external-plugin fixture continues to use
api.runtime.channel.inbound.buildContext(...)anddispatch(...); it adds no second public question API.The previous published head
94997b9540d7dfe0a3e0956e603e4b5b7744f51bhad full CI run 37202689210, which completed with 91 successful jobs, 15 skipped jobs and two failed jobs. It tested merge5d3a6e61825c425f993581db500b83578c7e7853(tree3dfddc6bb8ebd7512a954fd4a8d1b9aa6c54652f), combining that previous head with main85124fe108f74a7cfc52d4c5a0cf5fc589583fd6. The earlier fallback integration failure is repaired and its compact shards passed. The same CI aggregate also passed public-plugin ask_user acceptance in 13.472 seconds. The only actual test failure is Gateway SIGKILL/restart recovery, waiting 120 seconds atgateway-kill-restart-send.e2e.test.ts:123; the other failed job is its CI-gate mirror.A bounded, executed Linux comparison built fresh qaRuntime separately for that actual main parent and tested merge, using frozen dependencies, Node 24.19.0, pnpm 12.5.1 and the canonical singleton shard runner with two-CPU process affinity. Both failed at the same unchanged 120-second assertion (main: 264.54 seconds overall; merge: 270.93 seconds). Both retained only an inbound bus message and showed cold database refusal, later background admission recovery, no startup-orphan/recovery dispatch marker and
skipped:duplicate. Source and lock bytes/mtime/ctime stayed unchanged, both canonical build stamps passed, and owned child processes were joined. This supports a shared baseline failure for this test, rather than a PR-only failure; it does not establish a single root cause or waive red CI. The host had approximately 24 GiB RAM versus CI's 8 GiB; these two singleton runs used fresh compiled generations instead of CI's persistent caches and did not replay the predecessor. Only the merge additionally logged a late heartbeat recovery-claim change; that variation is retained.ClawSweeper revision 32 reviewed candidate
94997b9540d7dfe0a3e0956e603e4b5b7744f51b: no introduced actionable code or security findings, previous invalid-answer finding resolved, and terminal proof sufficient. Its remaining before-merge compatibility heuristic requires human confirmation; the same report recognizes no stored-format change. That previous head remained red pending recovery triage or a maintainer decision. Fresh CI and ClawSweeper must be matched to the refreshed candidate SHA above; these historical results are not transferred to it. No bot-managed labels were changed.Per-file test cost
Measured unchanged head
fd9cd3f94d14b703315d4a635d96026779430237(treea10e67a6911cc75d96e50c17a46e4ee69724d94f, basebb5656bf89e230bb3d6c9040b1e9b86df0306439), using native pnpm 12.5.1 and Node 26.7.0 on macOS. Each executable test file below was run separately, sequentially, once withpnpm test <file> --maxWorkers=1. All 12 commands passed. The diff contains 13 test/support modules, butsrc/agents/harness/gateway-question.test-support.tsis support-only and has no standalone test invocation.Command wall is measured from process launch through canonical runner/worker completion, including setup, imports, cache validation and cleanup. Vitest duration is the separately reported invocation duration. CI times come from existing run 37214288661, whose actual tested merge is
f4182df89ad4f252c01e6416f296228c07c7d060with main parent704a21dd91ef8f645bfea0fd24ec4652515b45b9; they are not local-command timings. The CI column sums emitted, rounded case timings, not whole-file, shard or command wall: it omits hooks/import/setup and any unreported time. Every displayed case count matches the corresponding local passed count; identical parameterized labels remain separate occurrences. If a reporter omits fast-case timings, such sums are incomplete observations. Compact shards do not separately emit standalone per-file CI command wall, so that value is unavailable rather than inferred.pnpm test <file> --maxWorkers=1)packages/gateway-protocol/src/questions-validators.test.tssrc/agents/embedded-agent-runner/run/attempt-stream-prepare.question-authority.test.tssrc/agents/embedded-agent-runner/run/attempt-stream-prepare.test.tssrc/agents/embedded-agent-runner/run/attempt.queue-message.test.tssrc/agents/harness/gateway-question.test.tssrc/auto-reply/reply/agent-runner-steer-adoption.question-source.test.tssrc/auto-reply/reply/dispatch-from-config.question-custody.test.tssrc/auto-reply/reply/dispatch-from-config.question-fallback.test.tssrc/auto-reply/reply/reply-run-registry.question-claim.test.tssrc/config/sessions/session-entry-read.worker.test.tssrc/gateway/server-methods/question.source-binding.test.tstest/e2e/qa-lab/runtime/ask-user-channel-adoption.e2e.test.tsThe CI public-plugin QA additionally reports 13.218 seconds for the file, 13.214 seconds for its case, and 22.33 seconds for its singleton canonical shard. These scopes differ and are not summed.
These are measurements with existing compiler outputs and runtime assets retained, not cold-cache benchmarks. Canonical worker checks observed local cache hits and verified completed generations before returning. Each command still pays its own cache/current-input verification and project startup. The public E2E entrypoint additionally ran its required
tsdown.ai.config.tspackage preparation once (9.6 seconds); that overhead is included in its measured command wall. No cache was cleared, no freshness override was supplied, and no complete runtime build or full gate was repeated. The existing exact-head cold-build public-plugin proof remains separate evidence.The seconds-long owner tests protect distinct contracts: the attempt/question suites combine real run/source authority, worker-backed pending-input/transcript settlement and V2 Gateway-client transport refusal across awaited preparation; a stubbed resolver cannot establish that custody commits only after source persistence or that the transport emits zero final frames after revocation. The session-reader suite uses native SQLite readers/writers, aliases, incognito state and cleanup to prove currentness closes at the consumer boundary, including ordered and unordered callback composition. The source-binding suite exercises the real question server method and a separate SQLite writer to prove final commitment refuses foreign deletion while the question stays pending; this is already narrower than a full Gateway boot. Cheaper dispatch/registry tests cover branching, unsupported fallthrough, profile admission and parked-queue non-replay. The public-plugin E2E composition proves the production Gateway plus public inbound SDK adopts the answer before admitting a successor and preserves
/stop; helper-only tests cannot show the originating final reply and zero successor turns. No real external tenant delivery is claimed.Across all commands, HEAD, tree, tracked source bytes and timestamps, and lock bytes/mtime/ctime remained unchanged. Canonical workers returned through their owned completion/verification path; the final process inventory found no remaining Node/pnpm/OpenClaw process whose arguments reference this task clone. The canonical build/runtime stamp fields still match the prior exact-head proof. This cost supplement does not change the recorded red CI or ClawSweeper revision 33 disposition.