Repository navigation
fix(gateway): later CLI bridge calls fail after the listener's creator turn completes - #165428
Conversation
Keep the operator-authority detachment and real HTTP regression from the original contributor fix. Remove duplicate storage integration coverage, document the listener lifetime, and deduplicate response serialization without changing header or error ordering.
|
🦞👀 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. Reviewed October 5, 2026, 4:45 AM ET / 08:45 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR keeps the shared CLI tool bridge available after its creator’s invocation completes, adds an HTTP lifetime regression, simplifies response serialization, and documents the behavior. Merge readiness✅ Ready for maintainer review This remains a useful fix absent from current main and the latest release. The recorded exact-head validation resolves the previous review’s blocker; no actionable patch defect remains. Priority: P1 Review scores
Verification
How this fits togetherCLI-backed agents call Gateway tools through a shared loopback HTTP bridge. The listener lasts for the Gateway process, while each tool request carries its own grant and authorization. flowchart TD
A[CLI agent turn] --> B[Per-turn context grant]
B --> C[Shared HTTP bridge]
D[Gateway process lifetime] --> C
C --> E[Current grant and permission checks]
E --> F[Gateway tool execution]
F --> G[Tool result to CLI]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +20, Docs +1. Total +21 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep listener lifetime process-owned while every CLI request remains bound to its own current grant and final-effect authority. Do we have a high-confidence way to reproduce the issue? Yes: start the listener inside temporary operator-tool authority, expire that invocation, then call a tool over HTTP. Source explains the failure, and the recorded isolated negative control reproduces it; this reviewer did not run current main. Is this the best way to solve the issue? Yes: exiting the existing temporary-authority owner at listener creation repairs the lifetime mismatch without adding another authority owner or changing per-request authorization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f8749864dc4c. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
…r turn completes (openclaw#165428) * fix: later CLI bridge calls fail after listener creator completes * test: prove later MCP grants retain authorized state effects * refactor(gateway): focus MCP listener lifetime regression Keep the operator-authority detachment and real HTTP regression from the original contributor fix. Remove duplicate storage integration coverage, document the listener lifetime, and deduplicate response serialization without changing header or error ordering. --------- Co-authored-by: nano-richtera <[email protected]>
…r turn completes (#165428) * fix: later CLI bridge calls fail after listener creator completes * test: prove later MCP grants retain authorized state effects * refactor(gateway): focus MCP listener lifetime regression Keep the operator-authority detachment and real HTTP regression from the original contributor fix. Remove duplicate storage integration coverage, document the listener lifetime, and deduplicate response serialization without changing header or error ordering. --------- Co-authored-by: nano-richtera <[email protected]> (cherry picked from commit 488c0f0)
Backport openclaw#165428 to the extended-stable loopback listener. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: later CLI bridge tool calls can fail with “operator tool invocation authority expired” after the invocation that first started the shared MCP listener completes.
User Impact
CLI-backed agents can keep using Gateway tools across later turns without restarting the Gateway. Each request still needs its own active grant and permissions. No configuration changes or migrations are required. This is a listener-lifetime fix, not a general native-agent continuation repair.
Why This Change Was Made
Start the process-owned listener outside its creator's temporary operator-tool authority using the existing authority owner's exit helper. Per-request grant, caller, cancellation, and dispatch checks stay intact.
Keep the focused real-HTTP lifetime regression. Remove the added storage integration test and its routing entry: dispatch scope ceilings, expired authority, grant revocation, and commit admission already have owner coverage. Simplify duplicate batch/single-response serialization while preserving serialization before headers are sent, and document the shared listener lifetime.
This additional context leak was found during the related request-scope work in #157144; this PR does not duplicate that work.
Evidence
Verified candidate:
20b41e5ff7aa36a8cf4a158f559242eaafe3dd0f. Execution environment: isolated, secretless Crabbox AWS leasecbx_62cebfdf14b9, Linux x64, Node 24.21.0, pnpm 12.5.1. The trusted main bootstrap checked the exact head and absence of an instance role; hydration and Tailscale were disabled. The lease is stopped.pnpm tsgo:core && pnpm test src/gateway/mcp-http.async-scope.test.ts --maxWorkers=1: passed. Core typechecking completed successfully, followed by 3 passing tests.pnpm test src/gateway/mcp-http.async-scope.test.ts --maxWorkers=1took 38.61s wall time, including about 2.66s in test bodies. Cold compiled-worker preparation took 21.23s; compilation and transforms dominate the command time. A real listener is necessary because listener creation is where the temporary authority is retained.src/gateway/mcp-http.tswith its merge-base version fromb2b434acbc624ed0c212fa2941dc9ac1fa5f1731, then ranpnpm test src/gateway/mcp-http.async-scope.test.ts --maxWorkers=1 -t 'does not inherit an expired operator-tool invocation'. 1 failed, 2 skipped, as expected, in 31.54s wall time. The tool response containedoperator tool invocation authority expiredwithisError: trueinstead of a successful result. Restored the candidate file afterward and confirmed clean source status.git diff --check: passed. Independent Codex autoreview through P2: scoped-clean. The shared local dependency installation prevented local typechecking; the isolated remote typecheck above supplies that proof.The regression exercises the real HTTP listener and authority storage with synthetic tool resolution/execution. It does not claim full Gateway or model-backed CLI acceptance.
LOC versus
origin/main: production +10/-10 (net 0); tests +20/-0; docs +1/-0.Credit
Replaces #164944 by @nano-richtera (organization-owned fork does not accept maintainer pushes). Original fix and regression by @nano-richtera; maintainer cleanup by @steipete.
The two original contributor commits remain in this branch with their original authorship.
Co-authored-by: nano-richtera [email protected]