Skip to content

Fleet spawn --task and relay messages injected into a PTY agent arrive truncated to their tail (silent), and spawn reports failure on success #1890

Closed

Description

@miyaontherelay

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-mini also 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:true properly 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 --task and 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 spawn returns 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

  1. miyaontherelay commented on Oct 4, 2026

    @miyaontherelay
    ContributorAuthor

    Correction and addition from checking the transcripts on sf-mini again (2026-10-04):

    1. The sf-mini agents' idleness was an expired login, not (only) the truncation. All five transcripts end with the assistant text Login expired · Please run /login and 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.
    2. fleet spawn gives no signal that the spawned agent cannot authenticate. The node reported the launch, the agents appeared live on the roster and in fleet agent list (workerLiveness: live), and nothing surfaced the Login expired state. 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.
    3. fix-526 has 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).
  2. miyaontherelay commented on Oct 4, 2026

    @miyaontherelay
    ContributorAuthor

    Delivery soak results (2026-10-04). Script: relay#1896; real local-only broker /api/send to 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.

    Revision / CLI Observed result
    origin/main 3cfc0fd6 / Codex 50 B isolated send: HTTP 200, no file after 240 s. Snapshot still showed the message in the composer; broker reported idle, 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.
    relay#1893 d735b8da / Codex Exact files: 50 B (738 body bytes, 171.850 s), 150 B (845 bytes, 506.327 s), 1 KiB (1,726 bytes, 230.757 s), 4 KiB (4,798 bytes, 439.321 s). Agent file-write order was 50 B, 1 KiB, 4 KiB, 150 B. The 16 KiB payload yielded a 17,093-byte message and an injection_too_large dead letter after HTTP 200 queue acceptance; no file.
    relay#1891 e1fa080f / Codex Five sends HTTP 200, no files. Dead-letter reasons: 50 B and 4 KiB worker_exited; 150 B, 1 KiB, and 16 KiB harness acceptance could not be proven. A separate 50 B run also ended worker_exited; its worker log showed the Codex folder-trust dialog. This does not isolate the submission change from startup handling.
    relay#1893 / Claude Five sends HTTP 200, no files. Three dead letters were prompt_unproven; terminal transcript showed Claude asking whether to process the soak messages.
    relay#1891 / Claude Five sends HTTP 200, no files. The 50 B message dead-lettered as harness acceptance could not be proven; the broker ended blocked_on_send with 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.

  3. miyaontherelay commented on Oct 4, 2026

    @miyaontherelay
    ContributorAuthor

    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 shows Ran mkdir -p records and Worked for 1m 27s. It wrote no record file; the broker dead-letter reason was harness 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.

  4. khaliqgant commented on Oct 5, 2026

    @khaliqgant
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions