Skip to content

openclaw agent --json output polluted by plugin loading logs #51076

@Peters-Pans

Description

@Peters-Pans

Description

When running openclaw agent --agent <id> --json, plugin loading messages are printed to stdout, corrupting the JSON output that downstream consumers expect.

Steps to Reproduce

  1. Install a plugin that logs during load (e.g. memory-lancedb-pro)
  2. Run: openclaw agent --agent some-agent --message "hello" --json --timeout 60
  3. Observe stdout

Expected Behavior

Stdout contains only valid JSON (the agent result). All log messages (plugin loading, warnings, etc.) should go to stderr.

Actual Behavior

Stdout contains plugin loading messages mixed with JSON:

[plugins] memory-lancedb-pro: smart extraction enabled (LLM model: qwen3.5-plus, noise bank: ON)
[plugins] [email protected]: plugin registered (db: /Users/user/.openclaw/memory/lancedb-pro, model: jina-embeddings-v5-text-small, smartExtraction: ON)
[plugins] memory-lancedb-pro: diagnostic build tag loaded (memory-lancedb-pro-diag-20260308-0058)
[plugins] session-strategy: using none (plugin memory-reflection hooks disabled)
[plugins] girlfriend-control: loaded without install/load-path provenance; treat as untracked local code and pin trust via plugins.allow or install records (/path/to/index.ts)
[plugins] memory-lancedb-pro: loaded without install/load-path provenance; treat as untracked local code and pin trust via plugins.allow or install records (/path/to/index.ts)
{"runId":"...","status":"ok","result":{...}}

This breaks any programmatic consumer that parses result.stdout as JSON (e.g. json.loads(result.stdout) in Python).

Impact

  • Any backend/frontend that calls openclaw agent --json via subprocess and parses stdout will intermittently fail with JSON parse errors
  • The issue is intermittent because sometimes the JSON appears after the logs (parse succeeds), and sometimes stdout only contains logs (parse fails with Expecting value: line 1 column 1 (char 0))

Suggested Fix

When --json flag is set, route all non-JSON log output (plugin loading messages, warnings, etc.) to stderr instead of stdout. Only the final JSON result should go to stdout.

Environment

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