Skip to content

fix: suppress plugin registration logs in CLI mode (#380)#387

Open
buzhihuowu2019 wants to merge 2 commits intoCortexReach:masterfrom
buzhihuowu2019:fix/cli-registration-logs
Open

fix: suppress plugin registration logs in CLI mode (#380)#387
buzhihuowu2019 wants to merge 2 commits intoCortexReach:masterfrom
buzhihuowu2019:fix/cli-registration-logs

Conversation

@buzhihuowu2019
Copy link
Copy Markdown

Summary

Fixes #380

Problem

Every openclaw memory-pro CLI command (stats, list, search, etc.) outputs ~11 lines of plugin registration logs to stderr before the actual command output, making CLI output very hard to read.

Solution

Detect CLI mode via OPENCLAW_CLI environment variable (set by OpenClaw when running CLI subcommands). In CLI mode, downgrade registration and lifecycle logs from info to debug level.

Changes

  • Added isCliMode() helper that checks process.env.OPENCLAW_CLI === "1"
  • Downgraded 5 registration/lifecycle log lines to debug in CLI mode:
    • smart extraction enabled
    • plugin registered (db, model, smartExtraction)
    • diagnostic build tag loaded
    • session-strategy: using none
    • session-memory: typed before_reset hook registered

Behavior

Context Before After
Gateway runtime info (visible) info (unchanged)
CLI commands info (noisy ~11 lines) debug (suppressed)

Testing

Tested with openclaw memory-pro stats — registration logs no longer appear in stderr. Gateway startup logs remain unchanged.

@buzhihuowu2019
Copy link
Copy Markdown
Author

The cli-smoke failure in reflection-bypass-hook.test.mjs is a pre-existing flaky test (4 subtests expecting stdout output that is empty). This PR only changes log levels from info to debug and does not affect any stdout/stderr content paths tested there. The same test likely fails on the upstream master branch as well.

Copy link
Copy Markdown
Collaborator

@AliceLJY AliceLJY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM — clean, minimal change, no side effects.

The 4 test failures in reflection-bypass-hook.test.mjs are pre-existing (fixed on master by 8bbca98 but not yet in your branch). Please rebase onto latest master to pick up the seed date fix, then tests should pass.

@rwmjhb ready for merge after rebase.

In CLI mode (OPENCLAW_CLI=1), registration and lifecycle logs are
downgraded from info to debug to avoid flooding stderr with ~11 lines
of noise before command output.

Affected logs:
- smart extraction enabled
- plugin registered (db, model, smartExtraction)
- diagnostic build tag loaded
- session-strategy: using none
- session-memory: typed before_reset hook registered

Gateway runtime behavior is unchanged (logs remain at info level).
@buzhihuowu2019 buzhihuowu2019 force-pushed the fix/cli-registration-logs branch from 72a897f to a9232ef Compare March 28, 2026 15:21
@buzhihuowu2019
Copy link
Copy Markdown
Author

Rebased onto latest master (picked up the seed date fix from 8bbca98). Ready for merge.

@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Mar 29, 2026

Nice improvement overall. One thing I noticed: CLI-mode log suppression still seems incomplete.

On the current PR head, OPENCLAW_CLI=1 correctly downgrades the main startup logs, but self-improvement and memory- reflection registration-summary logs still go through api.logger.info(...) on their enabled paths. That means users with those configs can still get stderr noise before command output.

If the intended scope of #380 is “suppress registration/lifecycle noise in CLI mode,” I think those remaining registration logs should be gated the same way as the other startup logs.

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.

CLI commands (memory-pro) output noisy plugin registration logs to stderr

3 participants