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
- Install a plugin that logs during load (e.g. memory-lancedb-pro)
- Run:
openclaw agent --agent some-agent --message "hello" --json --timeout 60
- 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] memory-lancedb-pro@1.1.0-beta.9: 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
- OpenClaw version: 2026.3.13 (61d171a)
- OS: macOS 15.7.3 (Sequoia) / arm64
- Plugin: memory-lancedb-pro@1.1.0-beta.9
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
openclaw agent --agent some-agent --message "hello" --json --timeout 60Expected 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:
This breaks any programmatic consumer that parses
result.stdoutas JSON (e.g.json.loads(result.stdout)in Python).Impact
openclaw agent --jsonvia subprocess and parses stdout will intermittently fail with JSON parse errorsExpecting value: line 1 column 1 (char 0))Suggested Fix
When
--jsonflag 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