openclaw - 💡(How to fix) Fix Fix Clack terminal confetti leaking into --json machine-readable output [4 pull requests]

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…

openclaw sessions --json can emit Clack spinner/progress glyphs before the JSON payload when run in an interactive terminal, making the output invalid JSON and breaking jq.

Example observed output:

$ openclaw sessions --json --limit all
{
  "path": "/Users/username/.openclaw/agents/main/sessions/sessions.json",
  "count": 19,
  "totalCount": 19,
  "limitApplied": null,
  "hasMore": false,

Expected: with --json, stdout should contain JSON only.

Actual: stdout starts with Clack/TUI decoration, so parsers fail.

$ openclaw sessions --json --limit all | jq '.sessions[]'
jq: parse error: Invalid numeric literal at line 1, column 2

Error Message

$ openclaw sessions --json --limit all | jq '.sessions[]' jq: parse error: Invalid numeric literal at line 1, column 2

Root Cause

Machine-readable output must be byte-clean. Pretty startup decorations are fine for humans, but they must never appear on stdout for --json.

Otherwise every script has to add hacks like 2>/dev/null or strip leading garbage before piping into jq, which defeats the point of --json.

Fix Action

Fixed

Code Example

$ openclaw sessions --json --limit all
{
  "path": "/Users/username/.openclaw/agents/main/sessions/sessions.json",
  "count": 19,
  "totalCount": 19,
  "limitApplied": null,
  "hasMore": false,

---

$ openclaw sessions --json --limit all | jq '.sessions[]'
jq: parse error: Invalid numeric literal at line 1, column 2

---

^[[?25lâM-^TM-^B
âM-^WM-^G
^[[?25h{
  "path": "/Users/username/.openclaw/agents/main/sessions/sessions.json",

---

stdout glyph write: "│\n"
  at Object.rt [as start] (.../@clack/prompts/dist/index.mjs:98:316)
  at start (.../dist/progress-Dr4m3lDw.js:120:18)
  at createCliProgress (.../dist/progress-Dr4m3lDw.js:123:21)
  at runCli (.../dist/cli/run-main.js:598:27)

stdout glyph write: "◇  \n"
  at Object.stop (.../@clack/prompts/dist/index.mjs:101:43)
  at Object.done (.../dist/progress-Dr4m3lDw.js:150:18)
  at stopStartupProgress (.../dist/cli/run-main.js:607:20)

---

{
  "cli": {
    "progress": "on"
  }
}
RAW_BUFFERClick to expand / collapse

Summary

openclaw sessions --json can emit Clack spinner/progress glyphs before the JSON payload when run in an interactive terminal, making the output invalid JSON and breaking jq.

Example observed output:

$ openclaw sessions --json --limit all
{
  "path": "/Users/username/.openclaw/agents/main/sessions/sessions.json",
  "count": 19,
  "totalCount": 19,
  "limitApplied": null,
  "hasMore": false,

Expected: with --json, stdout should contain JSON only.

Actual: stdout starts with Clack/TUI decoration, so parsers fail.

$ openclaw sessions --json --limit all | jq '.sessions[]'
jq: parse error: Invalid numeric literal at line 1, column 2

Evidence / trace

The emitted bytes include terminal/progress glyphs before {:

^[[?25lâM-^TM-^B
âM-^WM-^G
^[[?25h{
  "path": "/Users/username/.openclaw/agents/main/sessions/sessions.json",

Tracing process.stdout.write shows the writes come from Clack spinner startup progress, not from the sessions command:

stdout glyph write: "│\n"
  at Object.rt [as start] (.../@clack/prompts/dist/index.mjs:98:316)
  at start (.../dist/progress-Dr4m3lDw.js:120:18)
  at createCliProgress (.../dist/progress-Dr4m3lDw.js:123:21)
  at runCli (.../dist/cli/run-main.js:598:27)

stdout glyph write: "◇  \n"
  at Object.stop (.../@clack/prompts/dist/index.mjs:101:43)
  at Object.done (.../dist/progress-Dr4m3lDw.js:150:18)
  at stopStartupProgress (.../dist/cli/run-main.js:607:20)

dist/sessions-BgxFE6IE.js correctly calls writeRuntimeJson(...); stdout is already polluted by the global CLI startup progress before command output.

Proposed fix

Please fix this centrally in CLI progress handling, not one command at a time.

Commit 1: make progress safe for machine-readable output

  • Never emit spinner/progress unless both:
    • the intended progress output stream is TTY-safe, and
    • stdout is TTY-safe, because Clack writes spinner glyphs to stdout.
  • Never emit any progress UI for machine-readable invocations, e.g. --json.

This should protect sessions --json and any other current/future JSON-producing commands.

Commit 2: add simple configuration

Add a simple config option:

{
  "cli": {
    "progress": "on"
  }
}

Allowed values:

  • on — default; progress UI allowed, but still suppressed for machine-readable output.
  • off — disable this progress/spinner UI globally.

No env var needed.

The second commit is optional and can be reviewed separately; the first commit is the correctness fix.

Why this matters

Machine-readable output must be byte-clean. Pretty startup decorations are fine for humans, but they must never appear on stdout for --json.

Otherwise every script has to add hacks like 2>/dev/null or strip leading garbage before piping into jq, which defeats the point of --json.

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 Fix Clack terminal confetti leaking into --json machine-readable output [4 pull requests]