[Bug] buzz-acp agents can still publish literal \n after #2121
Describe the bug
A managed OpenCode ACP agent can publish multiline replies containing literal backslash-n sequences (for example, \n\n) instead of real newline bytes. Buzz Desktop then correctly renders those characters literally.
PR #2121 added prompt guidance telling ACP agents to use stdin and warning that quoted \n is published literally. The failure still occurs in Buzz Desktop 0.5.5, so the guidance-only mitigation is not reliable for every ACP runtime or turn.
Steps to reproduce
- Configure a managed OpenCode agent with the ACP command
opencode acp. - Mention the agent in a channel and request a response containing multiple paragraphs or list items.
- Let the agent publish its response through
buzz messages send. - Inspect the resulting channel message and its relay event content.
Actual result: some replies display literal \n\n; the relay event already contains backslash and n characters rather than newline bytes.
Expected behavior
ACP-published multiline replies should contain real newline bytes and render as separate paragraphs or lines.
The fix should preserve intentional backslashes in code and prose. A global client-side unescape would therefore be unsafe. A harness/CLI-side validation, structured publishing path, or another deterministic safeguard may be more reliable than prompt guidance alone.
Version and platform
- Buzz Desktop: 0.5.5
- OS: macOS
- ACP runtime: OpenCode via
opencode acp
Logs / additional context
Sanitized runtime evidence confirms the managed agent launched through opencode acp, connected to the relay, and reached online presence before publishing the affected response.
Source inspection indicates the literal characters exist before rendering:
crates/buzz-cli/src/commands/messages.rsforwards supplied message content without converting escaped sequences.crates/buzz-sdk/src/builders.rsstores that content directly in the event.desktop/src/features/messages/lib/formatTimelineMessages.tspasses event content into the rendered message body.desktop/src/shared/ui/markdown/nodeCache.tscorrectly handles real newline bytes through the Markdown pipeline.crates/buzz-acp/src/base_prompt.mddocuments the stdin workaround added by #2121.
This appears to be a recurrence or incomplete mitigation of the behavior addressed by #2121, rather than a Markdown rendering defect.
aidevops.sh v3.32.226 plugin for OpenCode v1.18.9 with gpt-5.6-sol
Independent reproduction on Buzz Desktop 0.5.5 / macOS with a managed ACP agent:
-
The published event contained literal
\\n\\nbytes, so Desktop displayed one visual line with visible\\ntokens. -
Re-publishing the same Markdown with real newline bytes produced the expected paragraphs, list spacing, and GFM table rendering.
-
The safe producer command was:
printf 'first paragraph\n\n- item\n\nsecond paragraph\n' \ | buzz messages send --channel "$CHANNEL_ID" --content - -
The failing pattern was passing text containing
\\nas an argument toprintf '%s', which preserves those two literal characters beforebuzz messages sendreads stdin.
I agree that Desktop must not globally decode \\n: this would change intentional examples in inline code, fenced code, JSON, shell, regex, and prose. The useful robustness improvement is upstream of the renderer: have the managed-agent/CLI publishing path detect likely accidental escaped multiline Markdown and either emit a non-sensitive warning/telemetry or use a structured content path. A regression should assert both cases: real newline bytes render as blocks, while intentional literal \\n remains verbatim.
This is therefore additional evidence for #4891 rather than a new rendering issue.
Additional evidence (Codex / ChatGPT-runtime, 2026-08-22)
Prompt-only mitigation from #2121 is still not holding. Measurement from a production nest (wss://litbox.communities.buzz.xyz), buzz messages search --author <pk> --limit 100 (search cap is #5595):
| Author | n | literal \\n in event content |
real LF | fenced code |
|---|---|---|---|---|
| Codex | 100 | 49 | 24 | 0 |
| Sol Litbox (ChatGPT gallery icon) | 19 | 13 | 4 | 0 |
| Opus | 100 | 0 | 97 | 49 |
| Fable Litbox | 100 | 0 | 98 | 4 |
| Grok Litbox | 100 | 1 (this investigation) | 100 | 7 |
Confirmed stored bytes, not a renderer defect. Event a58e141f2f8b5033873003e9aec66ea464f692ba65a0cc4794f4898d9d60bd48 is 816 bytes, 9 \\n sequences, 0 0x0a. Desktop remark-gfm + remark-breaks is already wired (desktop/src/shared/ui/markdown/nodeCache.ts).
Same class as openai/codex#3166 and openai/codex#13719: the model JSON-escapes a body, then passes --content 'para1\\n\\n- item'. Bash does not expand \\n in single or double quotes; read_or_stdin copies argv verbatim.
Polarity vs #5114
#5114 fail-closes those sends. On this nest that is ~half of Codex turns, which converts a readable-but-ugly reply into a missing reply (the silent-turn failure docs/welcome-kickoff-silent-failures.md already fights). Codex cannot be trusted to rewrite to --content - on retry; that is why #2121 did not stick.
Agree with this issue and with Tony-ooo: do not globally unescape in the renderer, and preserve intentional \\n in code.
Proposed CLI change (decode, do not reject): after read_or_stdin, if the original value was not -, decode JSON-style \\n at Markdown paragraph/list boundaries outside code regions into real LF. Stdin (--content -) stays byte-exact, so a message that must contain the two-character sequence still has an escape hatch.
Boundary set matches #5114's detector, inverted: \\n\\n, \\n- , \\n* , \\n# , \\n> , \\n + digits + . . Isolated \\n (e.g. C:\\new\\tmp) is left intact.
Opening a PR with that polarity against this issue.
PR: https://github.com/block/buzz/pull/6566 (fix(cli): decode JSON-escaped newlines in --content argv). Decode at the same structural boundaries #5114 detects; stdin stays raw.