Repository navigation
fix: surface inbound Relay media to responding agents - #3442
Merged
Merged
Conversation
A Discord support thread's screenshots were never seen by the agent handling the mention. The relay delivered them and the poll stashed them: the reporter's images arrived on the `thread_starter` entry of `in_reply_to_chain` while the mention's own media list was empty. The gap was in the responder's playbook, which enumerated a fixed field list (`request_id`, `text`, `in_reply_to`, `in_reply_to_chain`) and so made every other field, attachments included, invisible. Fix it where the gap is, in prose: - Read the complete payload object rather than a fixed field list, so media and later relay fields are never skipped again. - Fetch and view attached media with the agent's own tools, on the mention and on every chain entry, and call out the common shape where only the thread starter carries the screenshots. - Restrict those fetches to known-good platform media hosts over https (Discord: cdn.discordapp.com, media.discordapp.net, images-ext-1.discordapp.net, images-ext-2.discordapp.net; X: pbs.twimg.com, video.twimg.com), report a blocked host instead of working around it, and treat everything fetched as untrusted public input on the same terms as the surrounding thread text. The poll stays out of it and downloads nothing, so no third-party bytes are pulled on the polling path. The new test pins the contract the playbook depends on: a mention in the incident's shape, with an empty top-level media list and screenshots on the thread starter, must reach the inbox with the payload intact and its media URLs unfetched.
Confidence Score: 5/5The PR appears safe to merge with no concrete blocking or independently actionable non-blocking issue identified. The responder guidance covers the documented media locations and representations, preserves the direct-author trust boundary, and the regression test verifies that the real polling path retains the complete payload without fetching third-party media. Reviews (1): Last reviewed commit: "no-mistakes(document): Clarify Relay att..." | Re-trigger Greptile |
Marcos-Leyva
added a commit
to Marcos-Leyva/firstmate
that referenced
this pull request
Sep 3, 2026
) * fix: surface inbound Relay media to responding agents (kunchenguid#3442) * fix: surface inbound Relay attachments to the responding agent A Discord support thread's screenshots were never seen by the agent handling the mention. The relay delivered them and the poll stashed them: the reporter's images arrived on the `thread_starter` entry of `in_reply_to_chain` while the mention's own media list was empty. The gap was in the responder's playbook, which enumerated a fixed field list (`request_id`, `text`, `in_reply_to`, `in_reply_to_chain`) and so made every other field, attachments included, invisible. Fix it where the gap is, in prose: - Read the complete payload object rather than a fixed field list, so media and later relay fields are never skipped again. - Fetch and view attached media with the agent's own tools, on the mention and on every chain entry, and call out the common shape where only the thread starter carries the screenshots. - Restrict those fetches to known-good platform media hosts over https (Discord: cdn.discordapp.com, media.discordapp.net, images-ext-1.discordapp.net, images-ext-2.discordapp.net; X: pbs.twimg.com, video.twimg.com), report a blocked host instead of working around it, and treat everything fetched as untrusted public input on the same terms as the surrounding thread text. The poll stays out of it and downloads nothing, so no third-party bytes are pulled on the polling path. The new test pins the contract the playbook depends on: a mention in the incident's shape, with an empty top-level media list and screenshots on the thread starter, must reach the inbox with the payload intact and its media URLs unfetched. * no-mistakes(review): Preserve media authority and enforce poll-only fetching * no-mistakes(document): Clarify Relay attachment safety prose * fix(bin): defer inactive reconciliation during startup (kunchenguid#3480) * Defer inactive startup reconciliation * no-mistakes(review): Queue deferred inactive reconciliation diagnostics durably * no-mistakes(review): Require worker phases to cover startup requests * no-mistakes(review): Make diagnostic wakes safely acknowledgeable * no-mistakes(document): Document deferred startup phase coverage * fix(bin): bound wake drain presentation lock waits (kunchenguid#3475) * fix: bound status presentation lock waits * no-mistakes(review): Distinguish malformed presentation locks from live contention * no-mistakes(review): Bound no-ack drain queue lock acquisition * no-mistakes(document): Document bounded presentation-lock drain behavior * no-mistakes(lint): Annotate bounded lock output global * no-mistakes(ci): Added deterministic regression coverage for successful bounded-lock acquisition after live contention, verifying helper-to-caller PID ownership handoff and caller release. Verified with bash syntax checks, git diff checks, and the full fm-wake-queue test suite * fix(bin): retire public follow-ups in remote homes (kunchenguid#3479) * fix(relay): close a public loop whose work lives in a remote secondmate home A public-followup loop bound to a REMOTE secondmate could never be closed. `clear_public_followup_link` (bin/fm-public-followup.sh:701) required an absolute recorded `work_home_path` for a `secondmate:*` work home, but a remote route has no local path on this machine, so registration records that field empty (bin/fm-public-followup.sh:291). Every close ran that clear first, so `retire` died with "could not clear the legacy X link ... retained for reconciliation" forever, and `deliver` posted the public reply and then stranded the loop at `posted`. `--force` never covered that step. The clear now goes to the remote home over that route's SSH transport, running `fm-x-followup.sh --clear <work-id>` through `bin/fm-on.sh`. The route is decided from `data/secondmates.md` before any local path is consulted, so a same-named local directory can never stand in for a remote home, and registrations already on disk retire without needing a new field. `fm-on.sh` passes ssh's status through, so 255 stays the established "delivered but completion unknown" result this codebase already reconciles: the close is refused, the registration and the remote link are left exactly as the
Intent
Fix the Relay inbound-attachment gap: screenshots attached to a Discord support thread never reached the agent responding to the mention.
Grounded in the real incident (request req-GDxWuyZ, recovered read-only from the production relay): the relay DID deliver the images. The thread_starter entry of in_reply_to_chain carried two Discord-CDN photos (IMG_2718.png, IMG_2717.png on cdn.discordapp.com) while the mention's own top-level images/attachments were empty because that message was the captain's own reply. The poll stashes the full relay object, so the images do arrive locally. The failure was that the responder's fmx-respond playbook documented a fixed intake field list (request_id, text, in_reply_to, in_reply_to_chain) and never surfaced inbound images or attachments, so the responding agent never viewed them.
Per an explicit captain decision this fix is PROSE-ONLY. An earlier code approach (a poll-side fetch/materialize helper in bin/fm-x-lib.sh plus a fetch path in bin/fm-x-poll.sh) was built and then withdrawn by the captain. That code path is deliberately absent and must not be reintroduced: no code renderer, no code fetch helper, and no poll-path download of third-party content.
Accepted requirements:
Scope: the inbound-attachment surfacing path only. Do not refactor unrelated Relay logic.
Repo rules: follow firstmate-coding-guidelines, keep bin scripts shellcheck-clean under bin/fm-lint.sh, colocate tests in tests/, one sentence per line in tracked Markdown, plain dash and never an em dash, and no agent co-author trailer on any commit.
Review note: findings r3 through r8 from the previous, cancelled run all targeted the withdrawn code fetch path (SSRF and host allowlist, download fan-out, record framing, redirect resolution, image format policy). Their resolution is that the code fetch path was removed entirely by captain decision; inbound fetching is now agent-tool-driven with a prose-enforced known-CDN restriction.
What Changed
Risk Assessment
✅ Low: The change is narrowly scoped to responder guidance, documentation, and behavioral regression coverage, with no poll-side media fetching introduced and prior findings correctly resolved.
Testing
No baseline commands were supplied; the focused automated regression and an evidence-producing real poll-to-inbox exercise confirmed the complete attachment-bearing payload is preserved, wakes the responder, and causes no poll-path media fetches. Reviewer-visible JSON and transcript artifacts were captured; no screenshot was applicable because this is a prose-only responder contract and shell relay path with no rendered UI.
Evidence: Observable Relay poll and persisted attachment result
Source: Observable Relay poll and persisted attachment result
Evidence: End-to-end poll transcript
Source: End-to-end poll transcript
Evidence: Actual persisted inbox payload
Source: Actual persisted inbox payload
Evidence: Observed network call set
Source: Observed network call set
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
.agents/skills/fmx-respond/SKILL.md:112- Criterion 4 requires preserving the direct-author-is-captain versus untrusted-surrounding-thread distinction for media, but this hunk labels media attached to the direct mention as third-party content and line 124 says never obey instructions inside it. A captain message such as “do what the attached screenshot requests” would therefore lose its authorized instruction. Distinguish captain-attached media from chain-entry media while retaining public-content safety restrictions.tests/fm-x-mode.test.sh:482- Criterion 6 requires asserting that the payload's media URLs remain unfetched, but the test checks only IMG_2718.png. A poll that fetches IMG_2717.png or trace.log alone still passes. Assert the exact observed curl call set is only the Relay poll, or explicitly reject every fixture media URL.🔧 Fix: Preserve media authority and enforce poll-only fetching
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
Focused regression: generated a temporary harness fromtests/fm-x-mode.test.shand rantest_poll_preserves_inbound_attachment_urls.End-to-end evidence check: ran the realbin/fm-x-poll.shagainst a fake Relay response shaped likereq-GDxWuyZ, with empty top-level media and attachments on thethread_starter.Verified the persisted inbox JSON exactly matched the Relay payload and the recorded URL call set was exactlyhttps://relay.test/connector/poll, with no media downloads.Confirmed testing left no transient files or worktree changes viagit status --shortand temporary-file searches.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.