Skip to content

[Bug]: Suppress non-JSON output when CLI option --json is specified #84293

@erhhung

Description

@erhhung

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When running a CLI command like openclaw nodes list --json, the CLI initializes various componenents, like plugins, on startup, which may try to emit log lines on standard output without knowing that output should only be JSON.

Steps to reproduce

  1. In the agent container, run openclaw nodes list --json 2> /dev/null

Expected behavior

When CLI option --json is used, the output should always be pure JSON. Initialization of components like plugins should force their output to standard error regardless if they already do that themselves.

Actual behavior

CLI output contains non-JSON log lines, which causes JSON parsing errors.

OpenClaw version

2026.5.18

Operating system

Ubuntu 24.04

Install method

Kubernetes/Helm

Model

openai-codex/gpt-5.4

Provider / routing chain

openclaw -> litellm -> chatgpt

Additional provider/model setup details

No response

Logs, screenshots, and evidence

node@openclaw-9ffcb8c66-bszj9:~/.openclaw$ openclaw nodes list --json 2> /dev/null

12:42:15 [plugins] [lcm] Transcript GC disabled (default false)
12:42:15 [plugins] [lcm] Proactive threshold compaction mode: deferred (default deferred)
12:42:15 [plugins] [lcm] migration step complete: step=ensureSummaryDepthColumn durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=ensureSummaryMetadataColumns durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=ensureSummaryModelColumn durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=ensureMessageIdentityHashColumn durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=ensureMessageLargeContentColumn durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=ensureMessagePartsTable durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=backfillMessageIdentityHashes durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=createMessagesIdentityHashIndex durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=ensureCompactionTelemetryColumns durationMs=1
12:42:15 [plugins] [lcm] migration step complete: step=ensureFocusBriefTables durationMs=0
12:42:15 [plugins] [lcm] migration step skipped: step=backfillSummaryDepths algorithmVersion=1 reason=already-complete
12:42:15 [plugins] [lcm] migration step complete: step=createSummariesDepthIndex durationMs=0
12:42:15 [plugins] [lcm] migration step skipped: step=backfillSummaryMetadata algorithmVersion=1 reason=already-complete
12:42:15 [plugins] [lcm] migration step skipped: step=backfillToolCallColumns algorithmVersion=1 reason=already-complete
12:42:15 [plugins] [lcm] migration step complete: step=ensureMessagesFts durationMs=0
12:42:15 [plugins] [lcm] migration step complete: step=ensureSummariesFts durationMs=1
12:42:15 [plugins] [lcm] migration step complete: step=ensureSummariesFtsCjk durationMs=1
12:42:15 [plugins] [lcm] Migration run completed during engine init: duration=21ms fts5=undefined
12:42:15 [plugins] [lcm] Migration successful — 34 tables: conversations, sqlite_sequence, messages, summaries, message_parts, summary_messages, summary_parents, context_items, large_files, conversation_bootstrap_state, conversation_compaction_telemetry, conversation_compaction_maintenance, focus_briefs, focus_brief_sources, lcm_migration_state, messages_fts, messages_fts_data, messages_fts_idx, messages_fts_content, messages_fts_docsize, messages_fts_config, summaries_fts, summaries_fts_data, summaries_fts_idx, summaries_fts_content, summaries_fts_docsize, summaries_fts_config, summaries_fts_cjk, summaries_fts_cjk_data, summaries_fts_cjk_idx, summaries_fts_cjk_content, summaries_fts_cjk_docsize, summaries_fts_cjk_config, sqlite_stat1
12:42:15 [plugins] [lcm] Ignoring sessions matching 1 pattern(s) from plugin config: agent:*:cron:**
12:42:15 [plugins] [lcm] Engine initialized for db=/home/node/.openclaw/.openclaw/lcm.db duration=77ms
12:42:15 [plugins] [lcm] Plugin loaded (enabled=true, db=/home/node/.openclaw/.openclaw/lcm.db, threshold=0.75, proactiveThresholdCompactionMode=deferred)
12:42:15 [plugins] [lcm] State dir: /home/node/.openclaw/.openclaw
12:42:15 [plugins] [lcm] Compaction summarization model: openai-codex/gpt-5.4 (default)
12:42:15 [plugins] [lcm] auto-rotate: phase=startup action=summary thresholdBytes=2097152 durationMs=150 bytesRemoved=0 scanned=0 eligible=0 rotated=0 warned=0 skipped=0 backupCreated=0 reason=completed
{
  "pending": [],
  "paired": [
    {
      "nodeId": "2099a8b7974cbbc84ee424c2293817f602fd31cbd2afb96af366065c8cd90234",
      "platform": "darwin",
...

Impact and severity

Automation scripts that expect pure JSON output fail to parse JSON output due to leading non-JSON log lines.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    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