Skip to content

fix(agents): allow configless gateway rebind to activate standalone owner#111841

Merged
Patrick-Erichsen merged 4 commits into
openclaw:mainfrom
xialonglee:fix/issue-111520-configless-setup-rebind-upstream
Jul 21, 2026
Merged

fix(agents): allow configless gateway rebind to activate standalone owner#111841
Patrick-Erichsen merged 4 commits into
openclaw:mainfrom
xialonglee:fix/issue-111520-configless-setup-rebind-upstream

Conversation

@xialonglee

@xialonglee xialonglee commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #111520

What Problem This Solves

Fixes an issue where operator admins on a configless gateway (no explicit model in openclaw.json, model resolved from a provider env key like OPENAI_API_KEY) are permanently stuck on the Control UI Model Setup page. Clicking "Test & use" fails with:

Connection failed: prepared model runtime owner was not committed after replacement

Because activation never commits, openclaw.setup.detect keeps returning setupComplete: false, so every admin device is bounced to /settings/model-setup?firstRun=1 from the default chat landing. On a multi-user trusted-proxy gateway this locks all admins out of the chat UI.

The only workaround is host-side CLI (openclaw models set openai/gpt-5.6-sol + gateway restart), which regular Control UI users cannot perform.

Why This Change Was Made

acquirePreparedModelRuntimeLease unconditionally calls rebindInputToCommittedConfiguredOwner when the gateway lifecycle is active and the requesting path has provenance: "run". On a configless gateway, no provenance: "configured" owner exists, so rebind throws PreparedModelRuntimeOwnerNotPublishedError with no fallback.

The sibling path loadPreparedModelRuntimeSnapshot already handles this by catching the same error and falling through to activateStandalonePreparedModelRuntime. This change adds a parallel guard in acquirePreparedModelRuntimeLease: catch the error, verify the requesting runtime has no matching configured owner (to preserve the error for stale-owner refresh), then let the raw input proceed to standalone lease publication.

The fallback predicate was refined from "any configured owner exists in the process" to "a configured owner matches this runtime's identity/directory", so a mixed gateway (one configured agent + one configless runtime) no longer incorrectly blocks the configless runtime.

User Impact

Operator admins on configless gateways can now complete Model Setup "Test & use" directly through the Control UI without host-side CLI intervention. The setup flow detects the provider-derived model, live-tests it, persists the config, and marks setup complete — all from the browser.

Evidence

Before fix

Gateway with empty openclaw.json, OPENAI_API_KEY set via env. Model Setup "Test & use" → error:

Connection failed: prepared model runtime owner was not committed after replacement for /home/openclaw/.openclaw/agents/main/agent

setup.detect continues reporting setupComplete: false, redirect loop persists.

After fix — real gateway proof

Started a clean-state gateway with no openclaw.json and a fake OPENAI_API_KEY:

OPENCLAW_STATE_DIR=/tmp/openclaw-proof-111841 \
OPENAI_API_KEY=sk-proof-fake-key-111841 \
node openclaw.mjs gateway run --port 18790 --auth token --token proof-token-111841 --allow-unconfigured

Gateway resolved the default model from the env key and became ready:

[gateway] agent model: openai/gpt-5.6-sol (thinking=medium, fast=off)
[gateway] ready

openclaw.setup.detect found the OpenAI API-key candidate:

node openclaw.mjs gateway call --url ws://127.0.0.1:18790 --token proof-token-111841 --json \
  openclaw.setup.detect --params '{}'
{
  "candidates": [
    { "kind": "openai-api-key", "modelRef": "openai/gpt-5.6", "credentials": true }
  ],
  "setupComplete": false
}

openclaw.setup.activate (Model Setup "Test & use") proceeded past prepared-runtime activation and reached the provider call instead of failing with the lifecycle error:

node openclaw.mjs gateway call --url ws://127.0.0.1:18790 --token proof-token-111841 --json --timeout 60000 \
  openclaw.setup.activate --params '{"kind":"openai-api-key"}'
{
  "ok": false,
  "status": "auth",
  "error": "403 Country, region, or territory not supported"
}

The request did not fail with prepared model runtime owner was not committed after replacement; it failed only at the provider auth step, which is expected with a fake/redacted key and confirms the configless runtime activated successfully.

Unit tests

✓ src/agents/prepared-model-runtime.test.ts — 26 passed
✓ src/agents/prepared-model-runtime.lifecycle.test.ts — 40 passed (66 total)

Includes a new regression test: a configless runtime activates standalone while another agent is configured.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jul 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. labels Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 20, 2026, 2:53 PM ET / 18:53 UTC.

Summary
The branch lets a run-provenance prepared-model runtime publish a standalone lease when no matching configured owner exists, and adds lifecycle regression coverage for configless and mixed-agent gateways.

PR surface: Source +28, Tests +30. Total +58 across 3 files.

Reproducibility: yes. in source and contributor evidence: a configless gateway with provider credentials, followed by openclaw.setup.activate, exercises the rebind path; this review did not independently run that gateway scenario.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #111520
Summary: This PR is the concrete candidate fix for the configless Model Setup activation failure documented in the linked canonical issue.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P2] The branch already contains the concrete repair and regression coverage; the remaining action is ordinary maintainer merge review of this PR rather than a separate repair job.

Security
Cleared: The diff is limited to prepared-runtime ownership logic and tests; it adds no dependency, workflow, permission, secret, or supply-chain surface.

Review details

Best possible solution:

Merge this narrow owner-lifecycle repair once the current head completes normal required checks, then let the linked canonical issue close through its merged fix.

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

Yes in source and contributor evidence: a configless gateway with provider credentials, followed by openclaw.setup.activate, exercises the rebind path; this review did not independently run that gateway scenario.

Is this the best way to solve the issue?

Yes. Reusing the same configured-owner identity/directory matching logic for the fallback is narrower and safer than suppressing all rebind failures or adding new configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4aaea7b07291.

Label changes

Label justifications:

  • P0: Without a host-side CLI workaround, a configless gateway can leave every operator admin trapped in the Model Setup redirect path and unable to reach chat.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes an after-fix clean-state gateway transcript showing setup activation reaches provider authentication instead of the prior prepared-runtime lifecycle error.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an after-fix clean-state gateway transcript showing setup activation reaches provider authentication instead of the prior prepared-runtime lifecycle error.
Evidence reviewed

PR surface:

Source +28, Tests +30. Total +58 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 49 21 +28
Tests 1 30 0 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 79 21 +58

What I checked:

  • Narrow lifecycle fallback: The branch catches the configured-owner rebind failure only when no configured owner matches the requesting runtime, preserving the existing error path for stale matching owners while allowing a configless runtime to continue to standalone publication. (src/agents/prepared-model-runtime.ts:278, b6ec377d8e4a)
  • Shared matching semantics: Configured-owner candidate selection is extracted from rebinding and reused by the fallback predicate, addressing the prior review concern that a different configured agent in the same process must not block a configless runtime. (src/agents/prepared-model-runtime.owner.ts:85, b6ec377d8e4a)
  • Regression coverage: The added lifecycle test covers both a gateway with no configured owners and the mixed case where another agent is configured but the requesting runtime has no matching configured owner. (src/agents/prepared-model-runtime.lifecycle.test.ts:313, b6ec377d8e4a)
  • After-fix gateway behavior: The PR body records a clean-state gateway run and direct setup activation call that reaches the expected provider-authentication response instead of prepared model runtime owner was not committed after replacement; this is real terminal proof for the lifecycle regression. (b6ec377d8e4a)
  • Canonical remaining report: The linked report remains open and is the canonical user-impact record; this PR is its implementation candidate, so it should not be closed before the fix is merged.

Likely related people:

  • steipete: Provided the concrete configless-gateway reproduction and the observable Control UI failure that this lifecycle path is intended to repair. (role: linked-reproduction author; confidence: medium; files: src/agents/prepared-model-runtime.ts, src/agents/prepared-model-runtime.owner.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-20T14:30:33.037Z sha e9e0c32 :: needs real behavior proof before merge. :: [P2] Match the configured owner before suppressing the rebind error

Constrain the configless-gateway fallback in acquirePreparedModelRuntimeLease
to only suppress the rebind error when the requesting runtime has no matching
configured owner. Previously the predicate checked any configured owner in the
process, so a mixed gateway (one configured agent + one configless runtime)
would still throw and block configless Model Setup activation.

- Extract findConfiguredOwnerCandidates and hasConfiguredOwnerMatching from
  rebindInputToCommittedConfiguredOwner so the fallback reuses the same
  identity/directory matching criteria.
- Add regression test for a configless runtime activating standalone while
  another agent is configured.

Fixes review feedback on openclaw#111841.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 21, 2026
@Patrick-Erichsen Patrick-Erichsen self-assigned this Jul 21, 2026
Comment thread src/agents/prepared-model-runtime.ts Outdated
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(agents): allow configless gateway rebind to activate standalone owner This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head 8c78f98646ea8081258d05305d2fe47a0a3d0ef4:

  • Maintainer follow-up 8c78f98646e scopes the configless fallback to the reserved Model Setup identity and adds regression coverage proving ordinary unmatched agents still fail closed.
  • Focused prepared-runtime tests passed 67/67:
    • node scripts/run-vitest.mjs src/agents/prepared-model-runtime.test.ts src/agents/prepared-model-runtime.lifecycle.test.ts
  • pnpm format:check -- src/agents/prepared-model-runtime.ts src/agents/prepared-model-runtime.lifecycle.test.ts passed.
  • git diff --check passed.
  • Fresh autoreview completed with no actionable findings.
  • Repo-native scripts/pr prepare-run 111841 completed with GATES_MODE=hosted_exact_or_recent_parent for this exact head.
  • Exact-head hosted workflows passed: CI run 29803921759 and Workflow Sanity run 29803921760; openclaw/ci-gate is green.

Known proof gap: a separate Blacksmith Testbox lease was blocked by GitHub HTTP 429 during provisioning before tests executed. No code/test failure occurred; the exact-head hosted CI above is the merge gate used here.

@Patrick-Erichsen
Patrick-Erichsen merged commit 7d7c283 into openclaw:main Jul 21, 2026
119 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

@xialonglee
xialonglee deleted the fix/issue-111520-configless-setup-rebind-upstream branch July 21, 2026 07:26
vincentkoc added a commit that referenced this pull request Jul 21, 2026
* origin/main: (24 commits)
  fix(agents): keep compaction on live session model (#95713)
  fix(plugin-sdk): guard provider catalog live URL parsing against malformed responses (#109986)
  chore(cli): drop dead classifiers and single-use wrappers left by fallback removal (#112191)
  feat(ui): expand the lobster pet's random universe (#112073)
  chore(ci): audit dependency fingerprint exports (#112190)
  fix(ui): preserve graphemes in provider icons (#109509)
  fix(ui): align settings search with navigation rows (#112172)
  fix(agents): allow configless gateway rebind to activate standalone owner (#111841)
  fix(secrets): register secret targets for installed-origin plugins (#104347)
  improve(ui): show real machine identity in the place picker (#112162)
  fix: webChat scrollback history is too limited — older assistant replies and tool outputs disappear when scrolling… (#104250)
  test(ui): run DOM-free suites in Node (#112031)
  feat(nodes): make computer.act eligibility capability-based for desktop nodes (#112107)
  fix(apps): harden mobile gateway and watch state
  fix(ci): restore Z.AI API Platform validation (#112171)
  fix(ui): prevent Logs controls from overlapping (#112170)
  fix #95291: message tool fails to deliver files/images on Feishu (400 volc-dcdn / write ECONNRESET) while same Lark SDK upload succeeds standalone (#95514)
  refactor(cli)!: remove automatic gateway→embedded fallback from openclaw agent (#112074)
  refactor: move provider transports into packages/ai behind a typed host port (#111669)
  fix(anthropic): complete transcript reverse-scan windows across short reads (#109431)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 22, 2026
…wner (openclaw#111841)

* fix(agents): allow configless gateway rebind to activate standalone owner

* fix(agents): allow configless gateway rebind to activate standalone owner

* fix(agents): match configured owner before configless rebind fallback

Constrain the configless-gateway fallback in acquirePreparedModelRuntimeLease
to only suppress the rebind error when the requesting runtime has no matching
configured owner. Previously the predicate checked any configured owner in the
process, so a mixed gateway (one configured agent + one configless runtime)
would still throw and block configless Model Setup activation.

- Extract findConfiguredOwnerCandidates and hasConfiguredOwnerMatching from
  rebindInputToCommittedConfiguredOwner so the fallback reuses the same
  identity/directory matching criteria.
- Add regression test for a configless runtime activating standalone while
  another agent is configured.

Fixes review feedback on openclaw#111841.

* fix(agents): scope configless setup runtime fallback

---------

Co-authored-by: Patrick Erichsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

Model Setup 'Test & use' fails on configless gateways: prepared model runtime owner was not committed after replacement

2 participants