Repository navigation
Description
Problem
Long text injected into a spawned agent's terminal arrives truncated to its tail, silently. It affects agent-relay fleet spawn ... --task "<text>" and relay messages sent to a broker-registered agent. The agent then starts with a fragment that begins mid-sentence and no error is reported anywhere.
Evidence (2026-10-04, macOS, agent-relay 12.4.0, nodes report relay-broker/12.4.0)
I spawned six Claude agents with fleet spawn claude --node <n> --name <name> --cwd <repo> --task "<2.8-6.7 KB>". The first user message each agent's own transcript (~/.claude/projects/*/*.jsonl) recorded:
| agent | task sent | first user message received | starts with |
|---|---|---|---|
| mcp-events-strategy (finn-mini) | 6,686 B | 339 chars | with acceptance criteria, linked to the ADR, ... |
| fix-281-ops-list-creds (sf-mini) | ~3.6 KB | 198 chars | also does not skip the failing load. Fix: ... |
| fix-280-remote-path-layout (sf-mini) | ~3.7 KB | 343 chars | ent with the smallest safe change ... |
| fix-526-read-429-retry (sf-mini) | ~3.6 KB | 218 chars | amped), jitter and a small attempt cap ... |
| fix-282-login-no-open (sf-mini) | ~3.5 KB | 77 chars | ep other flags working, add a test. Your agent name is ... |
| fix-283-discovery-prefix (sf-mini) | ~3.5 KB | 4,467 chars, intact (arrived wrapped in a <pasted_content> block) |
full preamble |
- The surviving part is always the end of the text, with a different length each time, and one agent received everything. That points to a timing race, not a fixed size cap.
- A later relay message (1,966 B) to
mcp-events-strategy@finn-minialso arrived as only its last 213 chars. - Messages of 112-150 bytes sent to the same agents arrived intact (verified in the transcripts), so short pointer messages are reliable.
- The agents run with
--dangerously-skip-permissions. The four sf-mini agents sat idle for ~25 minutes on fragments (0 tool calls, no branches or PRs, so no side effects were observed), but a fragment could just as easily have been interpreted as an instruction.
Related: spawn reports failure when it succeeded
For the same spawns the CLI returned spawn_failed ("node ... reported completed for spawn without explicit spawned:true and ready:true proof") or spawn_unconfirmed ("may be running ... do not retry blindly") while the agent was live on the roster and fleet list. A retry here would have created duplicates.
A second wrinkle: one agent process shows up under two registrations, the broker name (mcp-events-strategy@finn-mini) and an auto desktop-session name (claude-relayfile-cloud-2b8538@...). An agent's own dedupe check ("another worker with my name is live") fired a false positive on itself.
Hypothesis (not verified; I could not find the injection code from here)
The broker types or pastes the task into the agent's TUI before the input box is ready (for example during startup or trust prompts), so the leading characters are swallowed. Chunked writes into a PTY could also drop data. Please confirm in the broker's pty/injection path.
Suggested fix
- Wait for a ready signal from the TUI before injecting; deliver the whole payload as one bracketed paste; read back (or have the agent echo) a hash of what it received.
- Report spawn success only after that confirmation, and surface
spawned:true, ready:trueproperly so success is not reported as failure. - Never truncate silently: reject over-limit messages with an explicit error, and document the limit.
- Offer a first-class file/brief mechanism (many fleet agents already use
~/relay-briefs/<name>.md). - Make the two registrations of one agent resolvable (alias or a single canonical name).
Acceptance
- A 10 KB
--taskand a 10 KB relay message reach the agent byte-for-byte across at least 20 cold-start spawns, verified from the agent transcript, or are rejected with an error. fleet spawnreturns success only for an agent that confirmed the full task.
Workaround (verified today)
Write the full brief to a file on the node (for example ~/relay-briefs/<name>.md) and send a pointer of 150 bytes or less: "Your full task is in ~/relay-briefs/.md on this machine. Read ALL of it first, then execute it." All the pointers arrived intact and the agents then reported correct phase summaries.
Activity
miyaontherelay commentedon Oct 4, 2026
Correction and addition from checking the transcripts on sf-mini again (2026-10-04):
Login expired · Please run /loginand 0 tool calls.fix-283, which received its 4,467-char task intact, is idle for the same reason. So "idle on fragments" in the report above overstates the harm of the truncation; the truncation itself (first user message = tail only) stands as measured.fleet spawngives no signal that the spawned agent cannot authenticate. The node reported the launch, the agents appeared live on the roster and infleet agent list(workerLiveness: live), and nothing surfaced theLogin expiredstate. A launch confirmation that waits for the first assistant turn (or checks the CLI auth) would have caught this immediately. Suggest adding it to the acceptance criteria next to the full-task confirmation.fix-526has only one user message in its transcript after I sent it a pointer, so a short message may also be lost sometimes (it may simply be that the agent was already stuck at the login prompt; not established).miyaontherelay commentedon Oct 4, 2026
Delivery soak results (2026-10-04). Script: relay#1896; real local-only broker
/api/sendto installed Codex 0.159.0 and Claude 2.1.289 PTY CLIs. Each revision was built from its own worktree after cleaning broker/relay-pty artifacts. One message per payload size (50, 150, 1,024, 4,096, 16,384 B); the full message body also includes test instructions and markers. JSON and terminal snapshots are retained under/tmp/relay-soak-*on the test host.origin/main3cfc0fd6/ Codexidle,ready=true, pending=0. Full five-size run: all sends HTTP 200, no files after 600 s; first message still in composer. No per-size truncation determination was possible.d735b8da/ Codexinjection_too_largedead letter after HTTP 200 queue acceptance; no file.e1fa080f/ Codexworker_exited; 150 B, 1 KiB, and 16 KiBharness acceptance could not be proven. A separate 50 B run also endedworker_exited; its worker log showed the Codex folder-trust dialog. This does not isolate the submission change from startup handling.prompt_unproven; terminal transcript showed Claude asking whether to process the soak messages.harness acceptance could not be proven; the broker endedblocked_on_sendwith four pending messages. A separate 50 B run wrote no file and showed the message in the composer.The file latencies include model reasoning and tool use, and this host had concurrent Rust builds and PTY sessions. Agent file-write order is not proof of wire reordering. No tail-only or head-only file was observed in these runs; the missing-file cases above are classified by their saved broker/terminal evidence, not as byte truncation.
miyaontherelay commentedon Oct 4, 2026
Follow-up on relay#1891: a separate 50 B Codex run with the folder-trust dialog handled (output
/tmp/relay-soak-pr1891-codex-50b) reached an agent turn: the saved terminal snapshot showsRan mkdir -p recordsandWorked for 1m 27s. It wrote no record file; the broker dead-letter reason washarness acceptance could not be proven. This confirms a turn started in that run, while the broker still reported delivery failure. The run does not establish whether the agent received the complete message body.khaliqgant commentedon Oct 5, 2026
Triage 2026-10-05: VALID-HAS-PR — not fixed on main (351a7da; #1896 only added the soak test). Garden PR #1893 (draft) targets it: bracketed paste + composer readiness + explicit failure on tail-only echo. Related non-Garden PR #1891 (verify PTY turn submission) overlaps the delivery-custody half.