Repository navigation
Description
Item 3 of 11 in the Crews: organic teamwork milestone.
The problem
When an agent gets a message from a crewmate, the envelope says:
[Cross-agent message from agent:j5:a2a:thread:j5:a2a:5d6a79cd… in project Billing]
That's the whole identity: an ID. The receiver can't tell from the envelope whether this is its Captain, a crewmate, or some Captain from another crew. To find out it has to remember its first-turn roster (which goes stale, see #681) or call j5_list_participants. Agents guess, or they treat every message the same.
Where this sits
This is part of "crewmates know each other." Names on messages (this issue), a crew-aware address book (#680), and join notices (#681) together mean an agent always knows who it's talking to and how they relate. It also makes the folded catch-up turn from #677 much easier to read, since each message in it says who it's from.
Definition
The docs PR on j5/crew-teamwork-docs writes the end state into the definitions, so read these first; this issue builds to them. Agent-to-agent communication AC22 and the Envelopes section, and Crews AC25.
What we already have
- The envelope template:
apps/server/src/j5/a2a/envelopes.v1.json:3(peerMessage) and:9(peerClosedMessage), filled in byapps/server/src/j5/a2a/EnvelopeFormatter.tsandformatAgentDeliveryEnvelopeinapps/server/src/j5/a2a/DeliveryTransport.ts:307. - Crew membership lookups:
AgentCrewInstanceService.ts(live crews, members, Captain). - The web renders A2A envelopes as cards by parsing that text (FORK.md cases 7, 14, and 24). Mobile shows the raw text.
- Carry J5 A2A metadata as a message-context record instead of text envelopes #285 plans to move this metadata out of text and into upstream's message-context records. If Carry J5 A2A metadata as a message-context record instead of text envelopes #285 lands first, do this in the record instead. If not, do it in the text and Carry J5 A2A metadata as a message-context record instead of text envelopes #285 carries it over.
Proposal
Add the sender's display name and its relationship to the receiver, worked out at delivery time:
[Cross-agent message from Critic (your crewmate in Invoice Export), agent:j5:a2a:… in project Billing]
[Cross-agent message from Release Lead (your Captain for Invoice Export), agent:j5:a2a:… in project Billing]
[Cross-agent message from Pricing Lead (Captain of Pricing Copy), agent:j5:a2a:… in project Billing]
[Cross-agent message from Docs Helper, agent:j5:a2a:… in project Billing]
Keep the participant id in there, since agents reply with it.
Acceptance criteria
- Every agent-to-agent envelope names the sender's display name and keeps its participant id.
- When sender and receiver share a live crew, the envelope says how they relate: your Captain, your crewmate (with the seat name), or a seat you command. When the sender captains a different live crew, the envelope says so and names that crew.
- The relationship is worked out when the message is delivered, so a seat added later reads correctly.
- A sender on a peer server shows the name that server reports, and no crew relationship.
- The web A2A cards still render messages stored before this change, and render new ones with the name. Mobile still shows readable text.
- Reply instructions and exchange ids are unchanged, and replying still works on Codex and Claude.
- Focused tests cover each relationship case and the no-crew case.
- If any upstream-owned file changes, it's recorded in
FORK.md.
Dependencies
- None blocking. Coordinate with Carry J5 A2A metadata as a message-context record instead of text envelopes #285 (whichever lands second carries the other).
- Helps Crews: a busy agent reads every message that arrived in one catch-up turn #677 and Crews: message the whole crew in one call #686, but neither needs it.
Activity