Repository navigation
Carry J5 A2A metadata as a message-context record instead of text envelopes #285
Description
Today
Every J5 A2A delivery is a user message whose text carries the J5 metadata as an XML-ish envelope (EnvelopeFormatter.ts): sender participant, origin Squadron, exchange ID and the reply instruction, plus the <j5_spawn_context>, <j5_crew_context>, <j5_crew_gate> and <j5_seat_finished> wrappers. The web UI parses that text back into cards (FORK.md cases 7, 14 and 24, plus the spawn brief from #186). Mobile has no J5 parser, so it shows the raw envelope.
Upstream's mechanism (live, advanced in #262)
Messages carry a structured context: { version: 1, records } (stored in context_json, upstream migration 051; introduced by pingdotgg#11265 and its stack).
- Text and payload: the text holds a reference link
[label](t3-context://v1/<kind>/<id>), and the record holds the payload. - Clients: every client renders records as chips, including mobile (
ThreadFeed.tsx,ComposerContextSheet.tsx). - Unknown kinds: kinds a client doesn't know are kept, not rejected (payload ≤ 64 KB).
- Model:
projectComposerContextForProviderturns each link into an inline marker and appends every referenced payload once in a trailing<t3_context version="1">block. Unknown kinds reach the model as JSON.
Plan
- Fork seam (small new FORK.md case). Add an optional
context?: OrchestrationMessageContexttoThreadManagementSendInputand pass it into themessage.dispatchcommandThreadManagementService.sendalready builds. That command already acceptscontext; only the server-side wrapper that agents and J5 use lacks it. Alternatively, J5 dispatches the command directly. Pick whichever keeps the queue and steer mode resolution intact. This is a natural candidate for the give-back backlog (Upstream give-back backlog (hold until V2 merges upstream) #276). - Delivery. J5 delivery writes the message body as plain text plus one reference link. The metadata (sender, Squadron, exchange, envelope kind, reply instruction) goes in a
j5-a2arecord. Do the same for spawn briefs, Crew context and gates, and seat-finished notices. - Web. The case 7, 14 and 24 renderers and
SpawnBriefread the record. The text parsers stay only for messages stored before the switch. - Mobile. It gets a clean bubble with a generic chip for free. Optionally add a small mobile renderer for the
j5-a2akind (sender name, Exchange state) that reads the record. - Behavior check. Agents now read the reply instruction as JSON inside
<t3_context>instead of envelope prose. Confirm that replies (send_messagewithexchange_id), one-shot messages, machine senders and spawn-brief handling behave the same on Codex and Claude before switching.
Related: #277 (senderThreadId) should land alongside or first. Update the "message-context records" note in docs/j5/research/upstream-convergence.md when this ships.
Activity