tmux/agent-send.sh: stamps a false sender whenever the sender's session is not on the destination socket #808
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
agent-send.shauto-detects the sender's session withtmux display-message -p '#S'.When the caller is not inside a tmux pane, tmux does not fail — it falls back to
the most-recently-active session on the socket. The wrapper accepts that value and
stamps it into the addressing preamble, so the message arrives claiming to come from
an agent that did not send it.
This defeats the stated purpose of the addressing standard. From
tools/tmux/README.md:A silently-wrong source label is worse than no label: the recipient cannot tell it is
wrong, and the documented "replies FLIP the preamble" convention then routes the reply
to the wrong agent — often back to the recipient itself.
Affected file
packages/mosaic/framework/tools/tmux/agent-send.sh(lines ~124-132):The
|| echo "?"fallback never fires, becausedisplay-messagesucceeds — itjust answers about a session the caller has nothing to do with.
Reproduce
From any shell that is not inside tmux, with at least one session on the socket:
Then send to a peer and inspect the delivered preamble:
The recipient sees
[<host>:peer-a -> <host>:peer-b] hello— wherepeer-ais anuninvolved session that happened to be most-recently-active. Observed in practice
sending from an orchestrator process running outside tmux: every message was
attributed to an unrelated worker seat.
Expected vs actual
source, or a hard error demanding
-S.it is wrong.
Suggested fix
Only trust
display-messagewhen the caller is genuinely inside a pane, and preferthe identity the launcher already exports.
start-agent-session.shexportsMOSAIC_AGENT_NAMEinto the pane, so it is the more reliable source:Note the dropped
-L "$SOCKET_NAME": inside a pane the caller's own session lives onwhatever socket it is on, which is not necessarily the destination socket passed via
-L. Using the destination socket to look up the sender is part of what makes thecurrent lookup wrong.
Whether an unknown source should be
?or a hard error is a design call —failing loudly may be preferable, since a message with no verifiable origin is
exactly what the addressing standard exists to prevent.
Notes
A regression test would need to invoke the script from outside tmux with a live
session present on the socket, and assert the preamble does not name it.
tmux/agent-send.sh: stamps a false sender in the preamble when invoked outside a tmux paneto tmux/agent-send.sh: stamps a false sender whenever the sender's session is not on the destination socket