openclaw - 💡(How to fix) Fix [Bug]: `models status --json` can emit auth-profile logs to stdout before JSON in route-first mode [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72962Fetched 2026-04-28 06:29:28
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1

On OpenClaw 2026.4.25, openclaw models status --json can emit a subsystem log line to stdout before the JSON payload. That makes stdout invalid JSON for automation that expects --json output to be parseable from byte 1.

Observed stdout shape:

[agents/auth-profiles] read anthropic credentials from claude cli keychain
{
  "configPath": "...",
  "agentId": "...",
  ...
}

Root Cause

Then the JSON object follows. Tools such as JSON.parse(...) or jq fail when reading stdout directly because stdout does not start with { or [.

Fix Action

Fix / Workaround

Verified Workarounds

Code Example

[agents/auth-profiles] read anthropic credentials from claude cli keychain
{
  "configPath": "...",
  "agentId": "...",
  ...
}

---

openclaw models status --agent <agent-id> --json > status.json
jq . status.json

---

[agents/auth-profiles] read anthropic credentials from claude cli keychain

---

log.info("read anthropic credentials from claude cli keychain", {
  type: keychainCreds.type,
});

---

routeLogsToStderrOnSuppress: false

---

OPENCLAW_LOG_LEVEL=silent openclaw models status --agent <agent-id> --json

---

OPENCLAW_DISABLE_ROUTE_FIRST=1 openclaw models status --agent <agent-id> --json
RAW_BUFFERClick to expand / collapse

Summary

On OpenClaw 2026.4.25, openclaw models status --json can emit a subsystem log line to stdout before the JSON payload. That makes stdout invalid JSON for automation that expects --json output to be parseable from byte 1.

Observed stdout shape:

[agents/auth-profiles] read anthropic credentials from claude cli keychain
{
  "configPath": "...",
  "agentId": "...",
  ...
}

Environment

  • OpenClaw: 2026.4.25
  • OS: macOS
  • Install kind: global package install
  • Relevant local auth shape: Claude CLI credentials are available via macOS keychain.

Reproduction

Run a JSON status command for an agent in a config that has Claude CLI auth/profile state:

openclaw models status --agent <agent-id> --json > status.json
jq . status.json

Actual Result

The command writes this non-JSON line to stdout before the JSON:

[agents/auth-profiles] read anthropic credentials from claude cli keychain

Then the JSON object follows. Tools such as JSON.parse(...) or jq fail when reading stdout directly because stdout does not start with { or [.

Expected Result

When --json is set, stdout should contain only the JSON payload. Informational logs should either be suppressed or routed to stderr.

Diagnostics

The emitted line appears to come from src/agents/cli-credentials.ts:

log.info("read anthropic credentials from claude cli keychain", {
  type: keychainCreds.type,
});

The likely route-first issue is in src/cli/route.ts. It calls applyCliExecutionStartupPresentation(...) with:

routeLogsToStderrOnSuppress: false

For non-routed commands, JSON mode normally calls routeLogsToStderr() so stdout stays clean. In the route-first path, that protection appears to be disabled, so info logs can leak to stdout before route handlers print JSON.

This is source-inspection-based inference plus local reproduction, not a confirmed maintainer diagnosis.

Verified Workarounds

Both of these produced stdout that starts with parseable JSON locally:

OPENCLAW_LOG_LEVEL=silent openclaw models status --agent <agent-id> --json
OPENCLAW_DISABLE_ROUTE_FIRST=1 openclaw models status --agent <agent-id> --json

Suggested Fix

For route-first commands, keep the same stdout-clean behavior as the normal commander/preaction path when JSON output mode is active. Concretely, either:

  • let applyCliExecutionStartupPresentation(...) call routeLogsToStderr() for routed --json commands, or
  • otherwise suppress/reroute subsystem logs before a routed JSON command prints its payload.

Suggested regression coverage:

  • routed models status --json emits parseable JSON from stdout byte 1,
  • routed JSON commands route non-payload logs to stderr,
  • routed non-JSON commands keep their current console behavior.

extent analysis

TL;DR

The issue can be fixed by modifying the applyCliExecutionStartupPresentation function to call routeLogsToStderr for routed --json commands.

Guidance

  • Verify that the issue is caused by the routeLogsToStderrOnSuppress: false setting in src/cli/route.ts by checking the code and testing the workarounds.
  • Consider setting OPENCLAW_LOG_LEVEL=silent or OPENCLAW_DISABLE_ROUTE_FIRST=1 as a temporary workaround to produce parseable JSON output.
  • To fix the issue, update the applyCliExecutionStartupPresentation function to call routeLogsToStderr when --json mode is active for routed commands.
  • Test the fix by running the openclaw models status --agent <agent-id> --json command and verifying that the output starts with parseable JSON.

Example

No code snippet is provided as the issue is related to the internal implementation of the openclaw command and requires modifications to the source code.

Notes

The suggested fix is based on the provided diagnostics and may require further testing and verification to ensure that it resolves the issue without introducing any regressions.

Recommendation

Apply the workaround by setting OPENCLAW_LOG_LEVEL=silent or OPENCLAW_DISABLE_ROUTE_FIRST=1 until a permanent fix is available, as this will produce parseable JSON output without modifying the source code.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: `models status --json` can emit auth-profile logs to stdout before JSON in route-first mode [1 comments, 2 participants]