Skip to content

Carry J5 A2A metadata as a message-context record instead of text envelopes #285

Open

Description

@Jacksondr5

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: projectComposerContextForProvider turns 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

  1. Fork seam (small new FORK.md case). Add an optional context?: OrchestrationMessageContext to ThreadManagementSendInput and pass it into the message.dispatch command ThreadManagementService.send already builds. That command already accepts context; 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).
  2. 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-a2a record. Do the same for spawn briefs, Crew context and gates, and seat-finished notices.
  3. Web. The case 7, 14 and 24 renderers and SpawnBrief read the record. The text parsers stay only for messages stored before the switch.
  4. Mobile. It gets a clean bubble with a generic chip for free. Optionally add a small mobile renderer for the j5-a2a kind (sender name, Exchange state) that reads the record.
  5. Behavior check. Agents now read the reply instruction as JSON inside <t3_context> instead of envelope prose. Confirm that replies (send_message with exchange_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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions