Skip to content

fix(cli): keep setup and agent help startup lazy - #133272

Merged
steipete merged 2 commits into
mainfrom
codex/qa-20260830-cli-help-lazy-actions
Aug 30, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-20260830-cli-help-lazy-actions

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #133271

What Problem This Solves

Resolves a problem where CLI help registration loads action-only runtime code before a command runs. Existing cold-help checks fail for setup, onboard, and agents; the same agent registration path also affects agent --help and agent exec --help.

Why This Change Was Made

Move onboarding rejection handling and agent exit finalization behind the existing async action boundary. Await the registration-owned validators without changing their rejection order, and replace five single-export loader wrappers with direct action imports. The canonical JSON rejection and exit-finalization owners stay unchanged.

Removing the broad loader types exposed unclear export ownership in the existing agent-exec command. Split its existing input/config preparation and result projection into owners the command actually consumes, with behavior preserved and test imports migrated without weaker assertions. Remove redundant casts at the new input owner and document its one required typed-merge assertion; the old assertion baseline shrinks without adding an allowance. This makes export ownership explicit instead of hiding unused exports behind whole-module type references. The tooling envelope consumer and the existing pinned-config loader exemption move to the matching owners.

Production: net -1 line, discounting the pure moves. Tests: +9 lines. No flags, configuration, dependencies, workflow, config policy, or result semantics change.

User Impact

Help text and command behavior are unchanged. Help registration avoids loading action-only code; onboarding still discovers provider metadata needed to render its provider-specific options. This does not claim that the entire CLI startup is runtime-free.

Evidence

  • Existing cold-help regressions reproduced before the fix; 241 tests across seven suites passed after the owner split, then both canonical boundary guards and the 52 input/config tests passed again after assertion cleanup, including JSON rejections, recommendation validation, parent/leaf options, agent exit behavior, config isolation, and terminal-result projection.

  • Fresh-process, source-mode proof through the actual setup/onboard fast-help renderer and the agent Commander registrations: all five help outputs are unchanged apart from the expected commit revision in the setup/onboard banner. Agent help no longer loads runtime or exit finalization; setup/onboard no longer load option rejection during registration.

  • Fresh autoreview and independent owner/caller/dependency review found no actionable issues. The moved input/config and projection blocks were independently compared against the original source, with no behavior changes or weaker test assertions.

  • Full thirteen-path canonical changed gate passed, including core/test/scripts typechecks, lint, all export scans, runtime cycles, and boundary guards.

  • Canonical pnpm build passed, including CLI bootstrap and SDK-export checks. Fresh source and built-launcher smoke covered setup, onboard, agent, agent exec, and agents help: all ten commands exited zero with empty stderr. Build metadata identifies 4417a65d98e24cc493cca375defda3c0db319e5d.

  • The temporary smoke comparator initially rejected the expected banner revision change. Raw output was preserved and verified; the remaining commands completed without repeating setup, the gate, or the build.

Exact reviewed head: 4417a65d98e24cc493cca375defda3c0db319e5d. Provenance: reproduced at source base 6549b0a7c534750d9d6cbef305233b162704b291; stable-release regression range not established. Required hosted CI run 33308980556 passed on this exact head, including openclaw/ci-gate.

Defer onboarding rejection and agent finalization imports until actions execute. Split agent-exec input/config preparation and result projection into actual production owners while preserving helper bodies and test contracts. Production LOC stays neutral.
@clawsweeper

clawsweeper Bot commented Aug 30, 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 cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete steipete self-assigned this Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 11:27
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 7:34 AM ET / 11:34 UTC.

ClawSweeper review

What this changes

The PR defers setup, onboarding, and agent action imports until command execution, and moves agent-exec input/config and result-projection helpers into focused modules.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-authored PR open for normal landing review. The introduced lazy boundaries repair the linked cold-help regression without a concrete correctness or security defect found; exact-head hosted checks are still pending.

Priority: P2
Reviewed head: 4417a65d98e24cc493cca375defda3c0db319e5d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A normal good maintenance patch: focused, source-supported, and free of actionable review findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body records fresh-process help traces, while reviewed source tests independently cover the deferred-import boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body records fresh-process help traces, while reviewed source tests independently cover the deferred-import boundary.
Evidence reviewed 6 items Current-main regression mechanism: The PR base still statically imports one-shot exit finalization during agent command registration, so help can load runtime-owned action code before an action runs.
Introduced lazy action boundary: Both parent-agent and nested agent-exec actions dynamically import their runtime, command, and exit-finalization owners only inside Commander action callbacks.
Onboarding callers preserve validation ordering: The now-async option resolver imports the rejection owner only on invalid action paths; both onboarding and setup callers await it before dispatching the wizard.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI command registrations must render help without initializing action runtime. When a user actually invokes setup, onboarding, or an agent turn, the registration hands execution to runtime-backed command owners.

flowchart LR
  A[CLI invocation] --> B[Command registration]
  B --> C[Help renderer]
  B --> D[Action handler]
  D --> E[Deferred runtime imports]
  E --> F[Setup, onboarding, or agent execution]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head hosted CI is still pending; this review does not replace required branch protection.
  • Complete next step (P2) - No mechanical repair remains; this maintainer-authored PR should proceed through its normal exact-head CI and landing process.
Agent review details

Security

None.

PR surface

Source -1, Tests +9, Other 0. Total +8 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 6 434 435 -1
Tests 4 31 22 +9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 3 3 0
Total 13 468 460 +8

Review metrics

Metric Value Why it matters
Production versus test delta production -1, tests +9; pure moves discounted The bug fix remains net-negative in production while adding focused cold-help coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #133271
Summary: This PR explicitly targets the linked cold-help regression and remains its open candidate fix.

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 deferred action-import boundaries and land after exact-head CI completes; no additional code change is indicated by this review.
  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 deferred action-import boundaries and land after exact-head CI completes; no additional code change is indicated by this review.

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

Yes—source provides a high-confidence reproduction path: the existing cold-help test targets the static registration imports present on the PR base, though this read-only review did not execute it.

Is this the best way to solve the issue?

Yes—the action callbacks are the correct ownership boundary for runtime-only imports, while the moved agent-exec helpers preserve their existing callers and focused tests.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4306140e0b88.

Labels

Label changes:

  • add P2: This repairs a bounded CLI import-isolation regression without evidence of data loss, security impact, or a blocked user flow.
  • 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 is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body records fresh-process help traces, while reviewed source tests independently cover the deferred-import boundary.

Label justifications:

  • P2: This repairs a bounded CLI import-isolation regression without evidence of data loss, security impact, or a blocked user flow.
  • 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 is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body records fresh-process help traces, while reviewed source tests independently cover the deferred-import boundary.

Evidence

What I checked:

  • Current-main regression mechanism: The PR base still statically imports one-shot exit finalization during agent command registration, so help can load runtime-owned action code before an action runs. (src/cli/program/register.agent-turn.ts:10, 4306140e0b88)
  • Introduced lazy action boundary: Both parent-agent and nested agent-exec actions dynamically import their runtime, command, and exit-finalization owners only inside Commander action callbacks. (src/cli/program/register.agent-turn.ts:83, 4417a65d98e2)
  • Onboarding callers preserve validation ordering: The now-async option resolver imports the rejection owner only on invalid action paths; both onboarding and setup callers await it before dispatching the wizard. (src/cli/program/register.onboard.ts:230, 4417a65d98e2)
  • Regression coverage: The expanded cold-import test exercises agent, agent exec, and agents help and asserts that command actions and default runtime were not loaded. (src/cli/help-cold-imports.test.ts:319, 4417a65d98e2)
  • Entry point and feature history: The core registry imports the agent registration on demand; local history identifies prior lazy-help and agent-exec work, though shallow/promisor history prevents a verified line-introduction pointer. (src/cli/program/command-registry-core.ts:120, 4417a65d98e2)
  • Codex dependency boundary: The Code Mode tooling edit only relocates a TypeScript envelope type import; no changed behavior imports, runs, or claims compatibility with the separate Codex harness, runtime, or protocol. (scripts/code-mode-model-matrix.ts:18, 4417a65d98e2)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Frank Yang: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete
steipete merged commit eeec0d4 into main Aug 30, 2026
249 checks passed
@steipete
steipete deleted the codex/qa-20260830-cli-help-lazy-actions branch August 30, 2026 11:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
* fix(cli): keep command actions out of help registration

Defer onboarding rejection and agent finalization imports until actions execute. Split agent-exec input/config preparation and result projection into actual production owners while preserving helper bodies and test contracts. Production LOC stays neutral.

* refactor(cli): complete agent exec owner migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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.

[Bug]: Setup, onboard, and agent help eagerly load action runtime

1 participant