Skip to content

fix(cli): preserve explicit read-only agent targets - #123868

Merged
steipete merged 2 commits into
mainfrom
codex/fix-readonly-owner-followups
Aug 14, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-readonly-owner-followups

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where read-only CLI commands could ignore an explicit agent or require an ambient default before reading it in multi-agent configurations. This affected models list, sandbox explain, and hook status reads, especially when no implicit fleet owner existed or the Gateway was unavailable/older.

Why This Change Was Made

Each command now resolves one explicit owner before any compatibility/default fallback and carries that owner through its workspace, auth, catalog, sandbox, or hook-status read. Hooks pass the selected agent to modern Gateways, retain it for local compatibility fallback, and no longer replace authoritative Gateway ownership errors with a local report.

The hook --agent option is intentionally read-only. Parent-scoped use with mutation subcommands is rejected rather than silently implying an agent-scoped config write.

User Impact

Operators can safely inspect a named agent in an explicit multi-agent fleet:

  • openclaw models list --agent <id>
  • openclaw sandbox explain --agent <id>
  • openclaw hooks list|info|check --agent <id>

No protocol, config, storage, or migration surface changes.

Evidence

Production LOC: +124/-34 (net +90) | Tests: +182/-4. The production growth establishes the missing explicit-owner boundary and narrows compatibility fallback so semantic Gateway errors remain authoritative.

The broader changed gate was attempted on the reused Testbox, but its stale base classified unrelated main drift and lacked the base pnpm-lock.yaml; exact-head native PR prepare/CI remains the authoritative broad gate.

@steipete
steipete requested a review from a team as a code owner August 14, 2026 22:18
@clawsweeper

clawsweeper Bot commented Aug 14, 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 docs Improvements or additions to documentation cli CLI command changes commands Command implementations docker Docker and sandbox tooling size: M maintainer Maintainer-authored PR labels Aug 14, 2026
@steipete steipete self-assigned this Aug 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 14, 2026, 6:37 PM ET / 22:37 UTC.

ClawSweeper review

What this changes

The PR carries an explicitly selected agent through read-only model listing, sandbox explanation, and hook-status reads, including compatible Gateway fallback behavior.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open: current main still forces a default agent before these reads, so the core repair remains necessary, but the updated models CLI reference makes an incorrect environment-variable claim.

Priority: P2
Reviewed head: 49fb512fd5a3ce64686aaf0335c7c03f201c3ccb

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The central repair and focused coverage are strong, but the changed CLI documentation is inaccurate.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records focused Testbox coverage.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records focused Testbox coverage.
Evidence reviewed 5 items Current-main defect: Current main resolves models list with the default agent and default agent directory before reading auth and workspace state, so an ownerless explicit fleet cannot perform this read without the proposed selection path.
Owner-boundary repair: The PR routes models list through a resolver that validates an explicit configured agent and derives its directory, while hooks and sandbox pass their resolved owner into the corresponding read path.
Gateway contract and sibling coverage: The existing Gateway handler accepts agentId, resolves it through the shared agent-selection error path, and its tests cover ownerless explicit fleets; the PR adds CLI coverage for forwarding and local fallback.
Findings 1 actionable finding [P2] Correct the omitted-agent behavior in the models reference
Security None None.

How this fits together

Read-only CLI commands choose an agent, then read that agent’s workspace, auth store, provider catalog, sandbox policy, or hooks. Results are returned either by the Gateway or by a local compatibility fallback.

flowchart LR
  A[CLI command and --agent] --> B[Agent selection]
  B --> C[Models, sandbox, or hooks read]
  C --> D{Gateway supports request?}
  D -->|Yes| E[Gateway response]
  D -->|No or unavailable| F[Local read-only fallback]
  E --> G[Operator output]
  F --> G
Loading

Before merge

  • Correct the omitted-agent behavior in the models reference (P2) - This newly includes list in the claim that omitted agent-aware commands use OPENCLAW_AGENT_DIR, but modelsListCommand falls through resolveModelsTargetAgent to resolveDefaultAgentId; only status implements an environment-directory override. Document list as using the configured default when --agent is absent, or implement the stated behavior.
  • Resolve merge risk (P1) - The PR reports production +90 lines for a bug fix; its duplicated known-agent normalization in hooks and models should not become a second long-term selection policy.
  • Resolve merge risk (P1) - The local promisor checkout could not materialize one base object and GitHub DNS was unavailable, so the complete three-way diff and linked Testbox artifact were not independently inspected.

Findings

  • [P2] Correct the omitted-agent behavior in the models reference — docs/cli/models.md:31
Agent review details

Security

None.

PR surface

Source +90, Tests +178, Docs +3. Total +271 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 4 124 34 +90
Tests 4 182 4 +178
Docs 3 9 6 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 315 44 +271

Review metrics

Metric Value Why it matters
Production versus test delta production +124/-34 (net +90); tests +182/-4 (net +178) The fix adds a meaningful new owner-propagation boundary for a bug fix, so duplicated agent-selection policy merits review before merge.

Stored data model

Persistent data-model change detected: serialized state: src/commands/sandbox-explain.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Correct the models reference so omitted models list is documented as using the configured default agent, then retain command-specific fallback policy while centralizing only the shared known-agent validation if this code is further simplified.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Correct the models reference so omitted models list is documented as using the configured default agent, then retain command-specific fallback policy while centralizing only the shared known-agent validation if this code is further simplified.

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

Yes, from source: on current main an ownerless explicit fleet reaches resolveDefaultAgentId before models list can read its selected agent, while the PR’s explicit-agent path avoids that default lookup.

Is this the best way to solve the issue?

Mostly yes: resolving one explicit owner at the read boundary is the narrowest repair, but the updated documentation must not claim that omitted models list honors OPENCLAW_AGENT_DIR.

Full review comments:

  • [P2] Correct the omitted-agent behavior in the models reference — docs/cli/models.md:31
    This newly includes list in the claim that omitted agent-aware commands use OPENCLAW_AGENT_DIR, but modelsListCommand falls through resolveModelsTargetAgent to resolveDefaultAgentId; only status implements an environment-directory override. Document list as using the configured default when --agent is absent, or implement the stated behavior.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3ef7f590a75d.

Labels

Label justifications:

  • P2: This repairs a bounded but important multi-agent CLI inspection workflow; the remaining defect is misleading operator documentation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records focused Testbox coverage.

Evidence

What I checked:

  • Current-main defect: Current main resolves models list with the default agent and default agent directory before reading auth and workspace state, so an ownerless explicit fleet cannot perform this read without the proposed selection path. (src/commands/models/list.list-command.ts:88, f22e4990c1fd)
  • Owner-boundary repair: The PR routes models list through a resolver that validates an explicit configured agent and derives its directory, while hooks and sandbox pass their resolved owner into the corresponding read path. (src/commands/models/list.list-command.ts:88, 49fb512fd5a3)
  • Gateway contract and sibling coverage: The existing Gateway handler accepts agentId, resolves it through the shared agent-selection error path, and its tests cover ownerless explicit fleets; the PR adds CLI coverage for forwarding and local fallback. (src/gateway/server-methods/hooks-status.ts:15, 49fb512fd5a3)
  • Documentation mismatch: The changed reference says omitted models list uses OPENCLAW_AGENT_DIR, but its new resolver falls directly to resolveDefaultAgentId; only models status has a dedicated environment-directory override. Public docs: docs/cli/models.md. (docs/cli/models.md:31, 49fb512fd5a3)
  • Feature history: Recent CLI hooks, model-list, sandbox, and explicit-multi-agent work is concentrated in the cited commits, with current-main lines blamed to the current main commit. (src/cli/hooks-cli.ts:85, c43ba8e3fca9)

Likely related people:

  • steipete: Peter Steinberger authored the recent explicit multi-agent, hook-status, sandbox, and model-list history that owns the selection behavior. (role: recent area contributor; confidence: high; commits: 1ca60fbc3a3f, c43ba8e3fca9, f22e4990c1fd; files: src/cli/hooks-cli.ts, src/commands/models/list.list-command.ts, src/commands/sandbox-explain.ts)
  • vincentkoc: Vincent Koc recently maintained the model-list implementation immediately adjacent to this explicit-agent change. (role: recent area contributor; confidence: medium; commits: 22a902c4cda9, 5ae401d9084f; files: src/commands/models/list.list-command.ts)

Rank-up moves

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

  • Correct the omitted-agent statement in docs/cli/models.md and retain the release-note context already present in the PR body.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-14T22:23:26.181Z sha 16f5d17 :: found issues before merge. :: [P2] Remove the release-owned changelog entry

@steipete
steipete merged commit 1c055ba into main Aug 14, 2026
181 checks passed
@steipete
steipete deleted the codex/fix-readonly-owner-followups branch August 14, 2026 22:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant