openclaw - ✅(Solved) Fix agents delete --force --json emits non-JSON 'Config overwrite:' prefix line to stdout [2 pull requests, 1 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#70889Fetched 2026-04-24 10:38:14
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2referenced ×2

openclaw agents delete <id> --force --json is documented (and commonly used) as emitting a machine-readable JSON summary to stdout. In practice, the command emits a Config overwrite: … status line to stdout before the JSON body, making the combined stdout stream invalid JSON.

Root Cause

json.tool rejects the stream because the "Config overwrite: …" line is not valid JSON.

Fix Action

Fixed

PR fix notes

PR #70897: fix: agents delete JSON output and shared workspace safety

Description (problem / solution / changelog)

Fixes #70889 and #70890.

#70889 — Config overwrite log leaks to stdout in --json mode

  • Added skipOutputLogs flag to ConfigWriteOptions
  • Suppresses Config overwrite: message when --json is requested
  • Passed through replaceConfigFile call chain in agents delete command

#70890 — agents delete recursively removes shared workspace

  • Added isWorkspaceShared guard to detect workspace path collisions
  • Skips workspace removal when another agent references the same directory
  • Reports workspaceSkipped: true in JSON output when guarded
  • Added regression tests for both fixes

Changed files

  • scripts/stage-bundled-plugin-runtime-deps.mjs (modified, +22/-0)
  • src/commands/agents.commands.delete.ts (modified, +28/-1)
  • src/commands/agents.delete.test.ts (modified, +78/-0)
  • src/config/io.ts (modified, +12/-0)
  • test/scripts/stage-bundled-plugin-runtime-deps.test.ts (modified, +68/-0)

PR #70917: fix(agents): suppress Config overwrite log in agents delete --json mode

Description (problem / solution / changelog)

Summary

openclaw agents delete <id> --force --json emits a Config overwrite: … diagnostic line before the JSON body, breaking machine-readable JSON parsing (e.g. | python3 -m json.tool).

The root cause is that replaceConfigFilewriteConfigFile logs config overwrite diagnostics via console.warn regardless of whether the caller requested JSON output.

Changes

  • Extend ConfigWriteOptions with an optional logger override (Pick<typeof console, "error" | "warn">).
  • Pipe the optional logger through the global writeConfigFile wrapper into createConfigIO.
  • In agentsDeleteCommand, pass a no-op logger via writeOptions when --json is set.
  • Add tests verifying the silent logger is passed in --json mode and omitted otherwise.

Test plan

  • pnpm test src/commands/agents.delete.test.ts passes (5/5).
  • pnpm test src/config/io.write-config.test.ts passes (11/11).
  • pnpm lint:core passes (0 warnings, 0 errors).
  • pnpm tsgo (core typecheck) passes.

Fixes #70889

Changed files

  • src/commands/agents.commands.delete.ts (modified, +7/-0)
  • src/commands/agents.delete.test.ts (modified, +49/-0)
  • src/config/io.ts (modified, +7/-1)

Code Example

# any existing agent
openclaw agents delete <id> --force --json | python3 -m json.tool

---

Config overwrite: /Users/<u>/.openclaw/openclaw.json (sha256 <a> -> <b>, backup=/Users/<u>/.openclaw/openclaw.json.bak)
{
  "agentId": "<id>",
  "workspace": "...",
  "agentDir": "...",
  "sessionsDir": "...",
  "removedBindings": 0,
  "removedAllow": 0
}
Expecting value: line 1 column 1 (char 0)
RAW_BUFFERClick to expand / collapse

openclaw agents delete --force --json emits non-JSON prefix line to stdout

Version affected: OpenClaw 2026.4.14 (323493f) on macOS

Summary

openclaw agents delete <id> --force --json is documented (and commonly used) as emitting a machine-readable JSON summary to stdout. In practice, the command emits a Config overwrite: … status line to stdout before the JSON body, making the combined stdout stream invalid JSON.

Reproduction

# any existing agent
openclaw agents delete <id> --force --json | python3 -m json.tool

Actual output:

Config overwrite: /Users/<u>/.openclaw/openclaw.json (sha256 <a> -> <b>, backup=/Users/<u>/.openclaw/openclaw.json.bak)
{
  "agentId": "<id>",
  "workspace": "...",
  "agentDir": "...",
  "sessionsDir": "...",
  "removedBindings": 0,
  "removedAllow": 0
}
Expecting value: line 1 column 1 (char 0)

json.tool rejects the stream because the "Config overwrite: …" line is not valid JSON.

Expected behavior

When --json is passed, stdout should be valid JSON (single document). One of:

  1. Suppress the Config overwrite: … line entirely when --json is active, OR
  2. Emit the Config overwrite: … line to stderr instead of stdout (most common convention), OR
  3. Include the config overwrite metadata as additional keys inside the JSON body itself (e.g. {"configOverwrite": {"path":"...","sha256Before":"...","sha256After":"...","backup":"..."}, "agentId":"..."...}).

Option 2 is the least disruptive for callers that currently parse the JSON with tolerance and seems consistent with the spirit of --json.

Impact

Breaks any script that pipes --json output to a JSON parser. Worked around downstream by reading capture_output and parsing only from the first { — but that shouldn't be callers' responsibility.

Discovered

2026-04-23 during Wave4u's independent verification pass of the agent-deployer meta-installer. Full trace in outbox/logs/spec_mover.jsonl + conversation thread.

extent analysis

TL;DR

The openclaw agents delete --force --json command should be modified to emit the "Config overwrite: …" line to stderr instead of stdout to produce valid JSON output.

Guidance

  • Verify the issue by running the reproduction command and checking the output with json.tool.
  • Consider modifying the openclaw command to redirect the "Config overwrite: …" line to stderr using a redirection operator (>&2) or a logging mechanism.
  • Update the openclaw documentation to reflect the expected behavior when --json is used.
  • Callers of the openclaw command may need to update their scripts to handle the changed output format.

Example

openclaw agents delete <id> --force --json 2>&1 | grep -v "Config overwrite:" | python3 -m json.tool

This example uses grep to remove the "Config overwrite: …" line from the output before piping it to json.tool.

Notes

The solution may require changes to the openclaw command's source code or configuration. The example provided is a temporary workaround and may not be suitable for all use cases.

Recommendation

Apply workaround: Redirect the "Config overwrite: …" line to stderr to produce valid JSON output, as this is the least disruptive solution for callers that currently parse the JSON output.

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…

FAQ

Expected behavior

When --json is passed, stdout should be valid JSON (single document). One of:

  1. Suppress the Config overwrite: … line entirely when --json is active, OR
  2. Emit the Config overwrite: … line to stderr instead of stdout (most common convention), OR
  3. Include the config overwrite metadata as additional keys inside the JSON body itself (e.g. {"configOverwrite": {"path":"...","sha256Before":"...","sha256After":"...","backup":"..."}, "agentId":"..."...}).

Option 2 is the least disruptive for callers that currently parse the JSON with tolerance and seems consistent with the spirit of --json.

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 - ✅(Solved) Fix agents delete --force --json emits non-JSON 'Config overwrite:' prefix line to stdout [2 pull requests, 1 participants]