Skip to content

fix: session creation targets the wrong Gateway after admission - #130686

Merged
shakkernerd merged 1 commit into
mainfrom
fix/session-create-gateway-binding
Aug 27, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix/session-create-gateway-binding

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #130112

What Problem This Solves

Fixes an issue where an agent creating a session could dispatch sessions.create
through a different in-process Gateway when the ambient Gateway changed after
the agent run was admitted.

Why This Change Was Made

Session creation now uses the same admitted-instance binding and settlement
revalidation as the other in-process Gateway tool paths. The request stays on
the Gateway that admitted the caller or fails closed if that Gateway is replaced
before dispatch or before the asynchronous result settles.

The transport fallback, signed visible-spawn policy, timeout and abort handling,
least-privilege scopes, trusted creation provenance, and model-authored request
parameters retain their existing boundaries.

User Impact

Agent-created sessions remain attached to the Gateway that owns the admitted
run. A retained tool cannot silently create the session through another active
Gateway after replacement.

Evidence

  • Current-main baseline: the focused two-Gateway regression failed on
    a87fb08e70e3e562c1056da6cf25372b6c64a383 because session creation omitted
    the admitted resolver and selected the ambient replacement Gateway.
  • Exact candidate: 153cc87b6f23a887e4e34c7edaed87900cb543e8.
  • Blacksmith Testbox through Crabbox:
    tbx_01m10qc1d1je4yk56m8vtyvdm5,
    https://github.com/openclaw/openclaw/actions/runs/33039301825.
  • The remote proof fetched the published branch, required FETCH_HEAD to equal
    the exact candidate, and verified that the published and synced trees both
    equal fff54b4d61c1d752df84d054bfe74ff361405bbb before testing.
  • Focused result: src/agents/tools/in-process-gateway.test.ts passes 13/13.
  • Changed gate: full core, coreTests check:changed plan passes, including
    production and test types, formatting, oxlint, import cycles, and repository
    guards.
  • The regression proves admitted resolver forwarding, zero ambient dispatches,
    replacement rejection before dispatch, and revalidation after both fulfilled
    and rejected asynchronous completion.
  • Repository autoreview: clean, no actionable findings.
  • Workloop independent review inspected the staged source and proof, marked the
    test-audit obligations satisfied, and found the resolver-forwarding repair and
    corrected regression sound.
  • Current origin/main at e87fcb0850697e747e1c73f414aabe4bd6155531
    has no intervening changes in either scoped file.
  • Production LOC: +22/-10 (net +12). Tests: +153/-0.
  • Provenance: the original creation helper was introduced by Peter Steinberger
    in refactor(sessions): canonical lineage model — creation provenance, fork ancestry, generation chain, typed row contract #111861 on July 23, 2026; fix: dashboard tools target the wrong Gateway after admission #130112 made the admitted resolver available to
    this path but did not forward it through creation dispatch.

Visual proof is not applicable because this changes backend Gateway ownership
without changing rendered UI. The two-Gateway dispatch regression is the direct
behavioral proof.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 27, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 12:25 AM ET / 04:25 UTC.

ClawSweeper review

What this changes

The PR binds agent-triggered session creation to the Gateway that admitted the run and rejects the call if that Gateway is replaced before dispatch or result settlement.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking correctness finding: the branch repairs a current-main Gateway-affinity gap, but this maintainer-owned, protected PR should remain open for human review and exact-head CI completion.

Priority: P1
Reviewed head: 153cc87b6f23a887e4e34c7edaed87900cb543e8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-backed repair with meaningful regression coverage and no blocking review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored backend routing repair is exempt from the external-contributor proof gate; its body also supplies a focused Testbox claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored backend routing repair is exempt from the external-contributor proof gate; its body also supplies a focused Testbox claim.
Evidence reviewed 6 items Current-main defect: Current main enters session creation through an ambient in-process context without passing the admitted resolver, while the dispatcher uses that resolver to select its request context.
Repair uses the existing binding primitive: The branch captures the caller resolver, binds it before dispatch, passes the bound resolver to the dispatcher, and revalidates it after settlement—the same owner-boundary pattern already used by the generic in-process helper.
Dispatcher honors the explicit binding: The in-process dispatcher resolves the request context from the supplied resolver before constructing the synthetic request and dispatching it.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/agents/tools/in-process-gateway.test.ts

Result: FAIL (failed) — step 1 run pnpm test src/agents/tools/in-process-gateway.test.ts: previous terminal command was still running after 30 seconds: "pnpm test src/agents/tools/in-process-gateway.test.ts"

$ node --import tsx scripts/test-projects.mts src/agents/tools/in-process-gateway.test.ts
[test] starting test/vitest/vitest.agents-tools.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130686-4euuKp/target

 ✓  agents-tools  src/agents/tools/in-process-gateway.test.ts (13 tests) 39ms

 Test Files  1 passed (1)
      Tests  13 passed (13)
   Start at  04:26:13
   Duration  9.41s (transform 7.30s, setup 981ms, import 8.03s, tests 39ms, environment 0ms)

[test] passed 1 Vitest shard in 16.04s

Assertions:

  • FAIL expect_output: keeps session creation on the admitted Gateway through async settlement

How this fits together

Built-in agent tools can make Gateway requests in process. An admitted run supplies the intended Gateway binding, which session creation uses to create and return a child session safely.

flowchart LR
  A[Admitted agent run] --> B[Captured Gateway binding]
  B --> C[Session creation tool]
  C --> D{Binding still current?}
  D -->|yes| E[In-process Gateway dispatch]
  D -->|no| F[Reject unavailable Gateway]
  E --> G[Session creation result]
Loading

Decision needed

Question Recommendation
After exact-head CI completes, should session creation adopt the same admitted-Gateway affinity and fail-closed settlement semantics as the other in-process agent-tool requests? Accept the bounded affinity repair: Merge after exact-head CI is green because the branch extends the established admitted-instance pattern without changing the transport fallback.

Why: The PR changes an authority-sensitive routing boundary and carries the protected maintainer label, so final acceptance requires explicit human judgment.

Before merge

  • Resolve merge risk (P2) - Production code grows by 12 lines for a creation-specific use of the existing binding flow; no safe net-neutral extraction was established without widening the trusted creation/fallback contract.
  • Complete next step (P2) - This protected maintainer PR has a sound bounded repair but needs explicit human acceptance and completion of its exact-head checks.
Agent review details

Security

None.

PR surface

Source +12, Tests +153. Total +165 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 22 10 +12
Tests 1 153 0 +153
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 175 10 +165

Review metrics

Metric Value Why it matters
Production versus regression coverage production +22/-10 (net +12); tests +153/-0 The production addition is confined to existing binding and revalidation primitives, with coverage for dispatch and both settlement outcomes.

Root-cause cluster

Relationship: canonical
Canonical: #130686
Summary: This PR is the focused remaining session-creation repair after the merged dashboard Gateway-affinity work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the creation-specific use of the canonical admitted-Gateway binder, then land only after exact-head CI confirms the focused regression and changed gate.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the creation-specific use of the canonical admitted-Gateway binder, then land only after exact-head CI confirms the focused regression and changed gate.

Do we have a high-confidence way to reproduce the issue?

Yes, source reproducible: current main dispatches this creation path without an admitted resolver, and the dispatcher otherwise selects its ambient context. The focused branch regression encodes the two-Gateway scenario, but was not executed in this read-only review.

Is this the best way to solve the issue?

Yes. The patch extends the existing binding and settlement-revalidation path while preserving the specialized trusted-creation fallback; moving this decision into the generic dispatcher would broaden unrelated request owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5e193d50ad8b.

Labels

Label changes:

  • add P1: Without the repair, an admitted agent run can create a session through a different active Gateway.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored backend routing repair is exempt from the external-contributor proof gate; its body also supplies a focused Testbox claim.

Label justifications:

  • P1: Without the repair, an admitted agent run can create a session through a different active Gateway.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored backend routing repair is exempt from the external-contributor proof gate; its body also supplies a focused Testbox claim.

Evidence

What I checked:

  • Current-main defect: Current main enters session creation through an ambient in-process context without passing the admitted resolver, while the dispatcher uses that resolver to select its request context. (src/agents/tools/in-process-gateway.ts:235, 5e193d50ad8b)
  • Repair uses the existing binding primitive: The branch captures the caller resolver, binds it before dispatch, passes the bound resolver to the dispatcher, and revalidates it after settlement—the same owner-boundary pattern already used by the generic in-process helper. (src/agents/tools/in-process-gateway.ts:235, 153cc87b6f23)
  • Dispatcher honors the explicit binding: The in-process dispatcher resolves the request context from the supplied resolver before constructing the synthetic request and dispatching it. (src/gateway/server-plugin-in-process-dispatch.ts:133, 153cc87b6f23)
  • Focused regression coverage: The added test covers admitted dispatch, replacement before dispatch, and replacement after both fulfilled and rejected asynchronous dispatch settlement. (src/agents/tools/in-process-gateway.test.ts:114, 153cc87b6f23)
  • History and sibling provenance: History identifies the prior merged dashboard-affinity repair as the nearby shared binding work; current-main blame shows the unbound creation branch carried by the current baseline commit. (src/agents/tools/in-process-gateway.ts:235, 730b6ef8faf3)
  • Unreleased branch head: The candidate commit is not contained by current origin/main or a local release tag, so it is not an implemented-on-main or shipped fix. (153cc87b6f23)

Likely related people:

  • shakkernerd: Authored the current branch and the prior merged dashboard-affinity repair that introduced the matching binding pattern. (role: recent Gateway-affinity contributor; confidence: high; commits: 153cc87b6f23, 730b6ef8faf3; files: src/agents/tools/in-process-gateway.ts, src/agents/tools/in-process-gateway.test.ts)
  • steipete: Feature history associates Peter Steinberger with the in-process session-tool refactor and canonical session-lineage work. (role: session-tool path owner in history; confidence: medium; commits: b85f421278ab, 099d6351b360; files: src/agents/tools/in-process-gateway.ts)
  • Vincent Koc: Current-main blame attributes the unbound creation branch to the latest baseline refactor commit. (role: recent baseline refactor contributor; confidence: medium; commits: a87fb08e70e3; files: src/agents/tools/in-process-gateway.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact-head changed checks complete before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@shakkernerd shakkernerd self-assigned this Aug 27, 2026
@shakkernerd
shakkernerd merged commit 3405561 into main Aug 27, 2026
218 checks passed
@shakkernerd
shakkernerd deleted the fix/session-create-gateway-binding branch August 27, 2026 04:51
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Agent-created sessions now stay bound to the Gateway that admitted the run and fail closed after replacement.

vincentkoc added a commit that referenced this pull request Aug 27, 2026
…-retirement-v13

* origin/main: (243 commits)
  fix: preserve Gateway error reasons in text logs (#130645)
  refactor(video): deduplicate generation contracts (#130635)
  fix(agents): preserve direct-message sender identity (#124548)
  fix(agents): preserve silent reply after settled tools (#130675)
  fix(talk): preserve replacement speech when an old utterance is canceled (#130687)
  fix(browser): preserve literal names and formatter-owned snapshot refs (#130599)
  fix(auth): reset only the profile replaced by a successful login (#124014)
  fix: bind session creation to admitted Gateway (#130686)
  refactor(qa-lab): reuse model reference splitter (#130317)
  docs(gateway): clarify independent HTTP endpoint switches (#130690)
  fix(ui): Control UI smooth scrolling ignores the reduced-motion preference (#130428)
  refactor(lmstudio): remove unreachable catalog merge (#130689)
  fix(crabbox): restore cloud machine CPU and RAM (#130684)
  fix(secrets): compare proxy bearer tokens directly (#127054)
  fix(matrix): show recovery key availability in text status (#128051)
  fix(ios): restore approval settings navigation and remove duplicate shell state (#130651)
  refactor(agents): use fixed tool-loop defaults directly (#130681)
  refactor(qa-lab): share process tree metric reader (#130419)
  refactor(models): simplify prepared owner access (#130683)
  fix(parallels): main install and update smoke cannot complete (#130658)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
Session creation now remains bound to the Gateway that admitted the agent run and fails closed if that Gateway is replaced before dispatch or completion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant