Skip to content

Redacted tool output should include a machine-readable marker so agents can detect redaction #68425

Description

@qiqi-victor

Problem

OpenClaw's redact-D4nea1HF.js automatically replaces apiKey / token / secret values with redacted placeholders ("***" for short values, "<prefix>…<suffix>" for long values) in tool outputs before passing them to the agent model. This redaction is completely transparent to the agent — there is no signal or marker indicating that the output has been redacted.

This creates a serious risk:

  • Agents that read config files via tools (terminal("cat openclaw.json"), file-read tool, etc.) see "apiKey": "***" as if it were the real value
  • Agents that then modify the config (e.g. change a different field via json.load → edit → json.dump) inadvertently write the redacted placeholder back to disk
  • All apiKey fields in the file become "***" — the config is now poisoned
  • Next startup: all providers return 401

Evidence

Real incident on 2026-04-18: An agent tried to update an unrelated model setting in openclaw.json. Its read of the file returned redacted values. Its write (full-file json.dump) overwrote 6 real apiKeys with "***". OpenClaw's subsequent .bak rotation fixated the pollution. The system was 401-failing for ~14 hours before root cause was identified (see #68423 for the related backup validation issue).

Proposed Fix

Make redaction explicit to downstream agents by emitting a machine-readable marker alongside the redacted output.

Option A: Structured tool response

{
  "output": "...",
  "redacted": true,
  "redacted_fields": ["models.providers.bailian.apiKey", "plugins.entries.brave.config.webSearch.apiKey"],
  "warning": "Output contains redacted values. DO NOT write this back to config files without re-fetching real values via openclaw config get <path> or environment variables."
}

Option B: Text marker appended to output

... (normal output) ...

[OPENCLAW-REDACTED] Fields redacted in this output: models.providers.bailian.apiKey, plugins.entries.brave.config.webSearch.apiKey
[OPENCLAW-REDACTED] These placeholders are NOT real values. Do not write them back to files.

Option C: Combined (structured + text)

Use a structured response when the tool protocol supports it, fall back to a text marker otherwise. Critical that the marker is always machine-parseable (stable prefix, no localization) so safety skills and linters can detect it reliably.

Why This Matters

Downstream safety measures (skills like config-safety, runtime linters) can detect redacted values in source files — but they cannot help if the agent writes them in the first place. An explicit redaction marker at the tool-output boundary would prevent an entire class of "agent writes back redacted value" incidents at the root.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions