Repository navigation
Conversation
…chat Gateway chat turns name their sender by the connection's client id, which is a fixed product name such as gateway-client, and Control UI turns carry no sender at all. Requester-scoped MCP keys sign-ins on that sender, so everyone behind one trusted-proxy backend client shared a single per-requester sign-in, and signed-in Control UI users got none. chat.send ingress now records the caller's verified Gateway profile on the run, for the person's own input only and never for a shared token or password login. The session MCP manager uses it as the requester ahead of the transport sender, keyed exactly as MCP Apps key a profile, so one sign-in serves that person's chat turns and MCP Apps. Queued runs from different profiles never collect into one run. Channel senders and connections without a verified profile are unchanged. Related: openclaw#138113
|
🦞👀 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: blocked before merge. What this changesThis PR uses verified Gateway profiles for requester-scoped MCP chat connections and checks their live authority before credentialed operations. Example: Alice and Bob chat through the same trusted-proxy backend identified as gateway-client.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 1 item remains This PR addresses a real requester-isolation gap that remains on current main; no concrete introduced defect was found, but the profile-first identity contract still needs a maintainer decision. Priority: P2 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherGateway ingress supplies verified caller identity to queued agent runs; the MCP manager selects requester credentials, and embedded or Codex tool executors use them through the existing MCP and OAuth owners. flowchart TD
A[Verified Gateway caller] --> B[Chat run context]
B --> C[Admitted operator authority]
C --> D[Requester MCP manager]
D --> E[Embedded or Codex executors]
E --> F[OAuth owner and credential store]
E --> G[MCP server]
Technical reviewBest possible solution: Approve a single profile-first requester contract and implement it through the existing run-authority, MCP manager, and OAuth owners while preserving sender-only credentials. Do we have a high-confidence way to reproduce the issue? Current-main sender-only selection establishes the path, and the contributor supplies a Gateway regression failing when Bob's sign-in supersedes Alice's; no target code was executed during this read-only review. Is this the best way to solve the issue? The implementation uses the existing verified caller and authority owners, preserves credential-key grammar, and removes the moved utility implementations from the materializer; its scope appropriately leaves HTTP and agent ingress for follow-up. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f2fccfab05f3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +189, Tests +1172, Docs +2, Other 0. Total +1363 across 31 files. Added test files: 3. 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. 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 (6 earlier review cycles)
Reviewed October 24, 2026, 2:36 PM ET / 18:36 UTC (Revision 7). |
A chat turn's verified Gateway profile was captured as a plain id at ingress and used later to select requester MCP credentials. Bind it to the run's admitted operator authority when the attempt is built, and have the session MCP manager recheck that binding right before it selects credentials. A revoked, closed or reassigned authority now throws there instead of signing in, and never falls back to the shared transport sender. Attempts carry only the bound profile. Adds a real-Gateway test: two people behind one trusted-proxy backend client get separate sign-in links, complete OAuth through the Gateway callback, and each reaches the MCP server with only their own token. A sign-in row the client's own identity already held is kept and never used. Related: openclaw#138113
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Tools a turn already holds now recheck the requester profile right before each sign-in start or call on a requester-scoped server, so a role change or revoked admission after acquisition stops the request before it leaves. The Gateway proof now changes a person's role mid-turn and checks that a shared-token backend client keeps the sign-in its own identity already holds. Related: openclaw#138113
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The argument helper that moved to agent-bundle-mcp-utility-executors.ts keeps its one type assertion, now with the SAFETY note a new file needs, and the materializer's grandfathered count drops by the one it no longer has. Related: openclaw#138113
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Related: #138113
What Problem This Solves
Fixes: people who chat with an agent through the Gateway share one per-requester MCP sign-in when they come in through the same backend client, and signed-in Control UI users get no sign-in at all, even though the Gateway has verified who each person is.
User Impact
User impact: each person with a verified Gateway profile (a signed-in Control UI user, or a person a backend client brings in through trusted-proxy auth) connects and uses their own account on an
oauth.identity: "per-requester"MCP server from chat. It is the same account their MCP Apps already use. One person's sign-in no longer serves everyone behind a backend client, and their pending sign-ins no longer replace each other.Unchanged: channel senders, shared token or password logins, system and internal turns, cron, subagents and heartbeats.
After updating, people who used a per-requester server through a backend client sign in once more. The row their client's shared identity already holds is kept and still serves connections without a verified profile; verified people neither use nor replace it.
Why This Change Was Made
A Gateway chat turn's sender is the connection's client id (
gateway-client, for example), or nothing for operator UI clients, and requester-scoped MCP keys sign-ins on that sender. The verified profile is already known atchat.sendingress, and MCP Apps already key a profile's sign-ins by it.chat.sendingress records the caller's verified profile on the run. It comes from the existing caller-identity authority, which is set only for a verified identity and never for the shared owner, and only the person's own input carries it, not system or internal turns.mcp-oauth-identity.tsis untouched). Rows a 2026.10.5 Gateway wrote load and work as before for the principals that own them (shown below with the published release).This follows the precedence proposed in #138113 (verified Gateway profile, else channel sender, else fail closed), as its own run fact rather than a change to
SenderId. Theagentmethod and the OpenAI-compatible HTTP surface mentioned there are not covered and keep today's behavior.Needs your decision on that identity contract: profile-first for direct Gateway chat turns, the profile tuple for resolver plugins, and the one-time sign-in for verified backend users.
Evidence
Through the CLI, upgrading from the latest stable release
A local harness (not part of this PR) runs
openclaw gateway runfrom the published[email protected](npmlatest), then from this branch's build at9c32a097d9, on one state directory. Every change goes through the CLI:doctor --fix,config patch,devices list/devices approve,users list, andgateway call users.setRole/agent.waitas the local shared owner. The other pieces are a local standard MCP OAuth server whose one tool names the account behind the bearer token, and a scripted model. Alice and Bob connect through one backend device asgateway-client, named by a trusted-proxy header over TLS.doctor --fixmigrates the state, this branch serves that client from the same row with no new sign-in.main), and each call reaches the server as that person's account.Matching Doctor and Gateway log lines (redacted)
In the repository
src/gateway/chat-send-requester-mcp-oauth.e2e.test.tsruns the same scenario in process againststartGatewayServer, the servergateway runstarts, with real WebSocket connect and device pairing,chat.send, OAuth discovery and PKCE, the Gateway's/oauth/mcp/callback, and the HTTP MCP transport. Its last step revokes a third person while their sign-in waits on the provider's authorization server discovery: once discovery answers, no client is registered and no pending sign-in is saved. A second case keeps a shared-token backend client on a row in the format 2026.10.5 writes.The same file on
mainfails while signing Alice in, because Bob's later sign-in start replaced the pending sign-in the two of them share:Unit tests:
agent-bundle-mcp-requester-profile.test.ts: the bound profile passes while it is the run's live operator authority; another profile, a revoked source (which stays retired) and a closed admission throw.agent-bundle-mcp-manager.requester-connect.test.ts: two profiles on one backend sender get separate links and store keys, and an authorized profile gets the real tools while the other still getsconnect. Once a profile loses its authority, acquisition throws without reading OAuth state. Executors the turn already holds then refuse before the runtime is reached, with no cancellation involved: the tool call, a new sign-in, and the resource and prompt listings and reads. A sign-in it starts hands the OAuth owner a login lifecycle with the call's abort signal, and a revocation mid-sign-in throws through it.agent-bundle-mcp-harness.test.ts: a session advertisescalendar__eventsfrom a requester who connected, and an unconnected profile's turn holds that tool as its sign-in. Once the profile loses its authority, the tool refuses before OAuth starts; while the profile is current, it starts sign-in, and a revocation during that sign-in stops it.agent-bundle-mcp-requester-connect.authority.test.ts: a real sign-in, through the real OAuth owner and an isolated state database, against a local OAuth provider. A requester who keeps access registers a client and gets a link. Another loses access while the provider's discovery is pending, with no cancellation anywhere: the owner's own recheck stops the sign-in before client registration, and nothing is saved.get-reply-run.requester-authority.test-support.ts(run byget-reply-run.media-only.test.ts): a verified caller's profile reaches the run; an unverified caller and a system turn get none. Smaller cases: the harness gate loads for a profile-only turn, and queued runs from different profiles get different collect keys.The sign-in cases fail without the login lifecycle (the connect executor called with only
{ redirectUrl }, as at63854c4022) and pass ate4077e0256:The e2e step above also passes without the lifecycle, because in that Gateway path the role change aborts the run as well; the real-owner test is the one that isolates the recheck.
Affected suites: every
agent-bundle-mcp-*suite, embeddedattempt-bundle-toolsand attempt dispatch, run params, follow-up execution and steering, allget-reply-run*and reply queue suites,agent-tools.prefix-stability, Codexrun-attempt.configured-mcp, MCP App runtime,chat-send-attach-identity.e2eand the new e2e.pnpm tsgo:core,pnpm tsgo:extensions,pnpm tsgo:test:src,pnpm tsgo:extensions:test, type-aware oxlint and oxfmt on the changed files,git diff --check, and the line-cap, assertion-safety, database, timeout-race and mock-exports ratchets pass.e4077e0256merges currentmainand moves the materializer's resource and prompt executors, unchanged, toagent-bundle-mcp-utility-executors.tsto stay under its line cap; at that head, the four typechecks, type-aware oxlint and oxfmt on the changed files, the line-cap ratchet,git diff --checkand the suites above (594 tests) pass. The CLI run above is from9c32a097d9.e19eb2a1bdadds a// SAFETY:note to the one type assertion that moved into the new file and lowers the materializer's assertion-safety baseline entry to match.987687d2damerges currentmain; its one conflict, inagent-bundle-mcp-manager.requester-connect.test.ts, keepsmain's new sharedmakeManagerRuntimestub and passes this PR's extra stub fields through it. At that head,pnpm tsgo:core,pnpm tsgo:test:src, type-aware oxlint and oxfmt on the changed files,git diff --check, the line-cap, assertion-safety, database, timeout-race and mock-exports ratchets, and this PR's suites with the neighbouringagent-bundle-mcpand reply queue suites (184 tests, including the new e2e) pass.4780daa569merges currentmainagain. Both conflicts are mechanical:maininlined its app-tool projection helper inagent-bundle-mcp-materialize.ts, next to the helpers this PR moves toagent-bundle-mcp-utility-executors.ts, and the resolution keeps both changes; inget-reply-run.requester-authority.test-support.tseach side added a case, and both stay. At that head,pnpm tsgo:core,pnpm tsgo:extensions,pnpm tsgo:test:src, type-aware oxlint and oxfmt on the changed files,git diff --check, the baseline and line-cap ratchets, and everyagent-bundle-mcp-*suite, theget-reply-run*and reply queue suites, attempt dispatch and bundle tools, Codexrun-attempt.configured-mcpand both e2e suites (615 tests) pass.