feat(amp-send,amp-reply): --body-file and --body-stdin for rich content#19
Open
joceqo wants to merge 1 commit into
Open
feat(amp-send,amp-reply): --body-file and --body-stdin for rich content#19joceqo wants to merge 1 commit into
joceqo wants to merge 1 commit into
Conversation
…ch content Both scripts take the message body as a positional shell argument. This breaks for rich content — backticks (command substitution), fenced code blocks, box-drawing characters, multi-line content with embedded quotes or `$var` references — even when the caller carefully escapes things. Observed in real multi-agent orchestration: an AI agent was asked to reply with a CLI UI mockup containing fenced code blocks with backticks and box-drawing chars. The agent's `amp-reply <msg-id> "<rich content>"` call entered a stuck loop in zsh — the agent attempted multiple workarounds (writing to a file, escaping backticks individually, switching quoting styles) and never recovered. Both scripts now accept the body via three mutually-exclusive sources: - Positional argument (existing, unchanged) - `--body-file PATH` read body from a file - `--body-stdin` read body from stdin If more than one is provided, the script errors clearly. Existing positional usage is unchanged — purely additive. Verified with rich content end-to-end: backticks, fenced code blocks, box-drawing chars (┌──┐ │ │ └──┘), Unicode (★), and $var-looking sequences all preserved byte-for-byte at the recipient. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
amp-sendandamp-replytake the message body as a positional shellargument. This breaks for rich content even when the caller carefully
escapes things:
$varor\sequencesReal-world failure mode
Observed in a multi-agent orchestration session: an AI agent was asked
to reply with a CLI UI mockup containing fenced code blocks with
backticks and box-drawing chars. The agent's
amp-reply <msg-id> "<rich content>"call entered a stuck loop in zsh.The agent attempted multiple workarounds (writing the body to a temp
file, escaping backticks individually, switching quoting styles) and
never recovered. Other agents in the same swarm — sending plain text —
delivered fine. The friction is specifically rich content + positional
shell arg.
Fix
Both scripts now accept the message body via three mutually-exclusive
sources:
--body-file PATH--body-stdinIf more than one source is provided, the script errors with a clear
message. If none is provided, it falls through to the existing
"missing body" path with help shown.
Existing positional usage is unchanged — these options are purely
additive. No breaking changes.
Verified end-to-end
Rich content (backticks, fenced code blocks, box-drawing chars
┌──┐,Unicode
★, and$var-looking sequences) preserved byte-for-byte atthe recipient via both
--body-fileand--body-stdin. Plainpositional usage continues to work.
ShellCheck
Both patched scripts pass
shellcheck. Only pre-existing info-levelwarnings remain (
SC1091about following the helper file,SC2181in amp-send.sh:293 about indirect
$?check) — both unrelated tothis change.
Why this matters for AI-driven AMP
Multi-agent orchestrations (especially LLM agents writing bash) are
exactly the case where positional shell args fail unpredictably. A
file-based body is far easier for an agent to compose reliably:
write to
/tmp/reply-$$.md, then callamp-reply <msg-id> --body-file /tmp/reply-$$.md.This makes amp-reply / amp-send safe to use as a target API for
agent code generation.
🤖 Generated with Claude Code