Skip to content

fix(cli): keep the metadata-only registration away from the host runtime - #996

Draft
gorkem2020 wants to merge 1 commit into
CortexReach:masterfrom
gorkem2020:fix/cli-metadata-registration-defers-runtime
Draft

fix(cli): keep the metadata-only registration away from the host runtime#996
gorkem2020 wants to merge 1 commit into
CortexReach:masterfrom
gorkem2020:fix/cli-metadata-registration-defers-runtime

Conversation

@gorkem2020

Copy link
Copy Markdown
Contributor

Summary

Current OpenClaw hosts register plugins in a cli-metadata mode to collect the CLI command tree before any runtime exists. In that mode api.runtime is a proxy that throws on access, and nothing registered there ever executes (the host loads the command's owning plugin again in full mode to run it). This plugin's register() wires the LLM client eagerly and feature-detects the host completion surface by reading api.runtime.llm, so every CLI process logged

[plugins] memory-lancedb-pro: smart extraction init failed, falling back to regex: Error: Plugin "memory-lancedb-pro" runtime is intentionally unavailable during "cli-metadata" registration. Declare root commands in the manifest's cliCommands or defer runtime access out of register().

on commands as harmless as openclaw memory-pro stats, and the metadata pass ran the whole LLM and admission wiring for a registration whose handlers never run. The gateway (full mode) was never affected.

Changes

  • index.ts: resolveRuntimeLlmComplete reads a throwing runtime as "unavailable" instead of propagating the error; register() skips the LLM client, smart extraction and admission wiring when api.registrationMode is cli-metadata (isCliMetadataRegistration), leaving the CLI tree registration in place; the root CLI registration now passes a parse-time descriptor (MEMORY_PRO_CLI_DESCRIPTOR) alongside commands, so the host can register memory-pro as a lazy placeholder.
  • openclaw.plugin.json: declares the memory-pro root command in cliCommands, the manifest surface the host's message points at, so help and activation planning resolve the owner without loading the plugin.
  • Tests: test/cli-metadata-registration.test.mjs covers the throw-safe probe, the mode check, a cli-metadata registration that registers the CLI tree without touching the runtime or logging an init failure, an unchanged full-mode registration (admission wiring still constructed), and the manifest declaration matching the registrar's descriptor. Registered in the npm test chain and the CI manifest (core-regression).

Notes

  • Hosts that predate registrationMode never set it, so the gate is inert there; the descriptor option is ignored by hosts that do not read it.
  • The direct-transport fallback for hosts without runtime.llm is unchanged; it simply no longer fires on the metadata pass, where it had nothing to do.

Verification

  • npm run build, npm test, the cli-smoke CI group, the new regression file (four of its six cases red against the previous code by construction), and the existing command-reflection-guard, llm-host-transport, llm-host-transport-composition, admission-control-host-transport, llm-transport-credential-hygiene and plugin-manifest-regression suites.
  • Observed on OpenClaw 2026.9.2: openclaw memory-pro stats printed the init-failure line before its output on every invocation; with this change the metadata pass logs a debug line and no warning.

Current hosts register plugins in a "cli-metadata" mode to collect the CLI
command tree before any runtime exists: api.runtime is a proxy that throws
on access, and nothing registered in that pass ever runs (the host loads
the command's owning plugin again in full mode to execute it). register()
wired the LLM client eagerly and feature-detected the host completion
surface by reading api.runtime.llm, so every CLI process logged "smart
extraction init failed, falling back to regex" and did the whole LLM and
admission wiring for a registration whose handlers never run.

The runtime probe now reads a throwing runtime as unavailable; register()
skips the LLM client, smart extraction and admission wiring under
cli-metadata registration while still registering the CLI tree; the root
CLI registration passes a parse-time descriptor next to the command name;
and the manifest declares the memory-pro root command in cliCommands, the
surface the host's own guidance points at.

Regressions: the throw-safe probe and the mode check, a cli-metadata
registration that registers the CLI without touching the runtime or
logging an init failure, an unchanged full-mode registration, and the
manifest declaration matching the registrar's descriptor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant