Skip to content

[Bug]: --json mode CLI stdout is polluted by plugin/bootstrap logs, breaking machine-readable output #37323

@furedericca-lab

Description

@furedericca-lab

Bug type

Behavior bug (incorrect output/state without crash)

Summary

Commands invoked with --json can emit plugin/bootstrap logs to stdout before the JSON payload, which breaks machine-readable CLI output and causes direct jq parsing to fail.

Steps to reproduce

  1. Use a setup where plugins are enabled and initialize during CLI startup.
  2. Run:
    openclaw plugins list --json | jq .
  3. Run:
    openclaw hooks list --json | jq .
  4. Observe that stdout may contain plugin/bootstrap log lines before the JSON payload.

Expected behavior

When a command is invoked with --json, stdout should contain only JSON. Non-fatal logs/warnings should go to stderr or be suppressed in JSON mode. Human text mode should remain unchanged.

Actual behavior

Commands that should be machine-readable can print startup/plugin log lines such as plugin registration / hook runner initialization before the JSON payload on stdout. This causes jq and other automation consumers to fail because stdout is no longer pure JSON.

OpenClaw version

2026.3.2 (85377a2)

Operating system

Linux 6.17.4-2-pve (x64) in LXC

Install method

npm global / CLI install

Logs, screenshots, and evidence

$ openclaw plugins list --json | jq .
[plugins] [email protected]: plugin registered (db: /usr/local/lib/openclaw-memory/lancedb-pro, model: gemini-embedding-001)
[plugins] self-improvement: integrated hooks registered (agent:bootstrap, command:new, command:reset)
[plugins] memory-reflection: integrated hooks registered (command:new, command:reset, after_tool_call, before_agent_start, before_prompt_build)
[plugins] hook runner initialized with 5 registered hooks
parse error: Invalid numeric literal at line 1, column 9

The same class of contamination was observed around other JSON-mode CLI startup paths because plugin/bootstrap logging happens early in startup.

Impact and severity

Affected: CLI users relying on --json for automation, scripting, and CI
Severity: Medium to High (breaks machine-readable contract for affected commands)
Frequency: Reproducible when plugin/bootstrap logs are emitted on startup
Consequence: JSON consumers fail, automation becomes brittle, and users must rely on wrappers or log-level workarounds instead of a stable JSON stdout contract

Additional information

This appears to be a core CLI/logging issue rather than a plugin-specific data bug. The expected fix direction is to ensure that when JSON mode is active, subsystem/plugin bootstrap logs are routed to stderr (or suppressed) while stdout remains reserved for JSON payloads only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions