Skip to content

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

Not planned

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.

Activity

  1. added
    enhancement
    on Sep 24, 2026
  2. bryantderosier commented on Dec 1, 2026

    @bryantderosier
    Collaborator

    Closing this as not planned. We never moved A2A metadata into context records. We kept the text envelope on purpose, and the problems this issue was trying to fix got solved another way.

    • We kept the envelope. D50 in docs/j5/product/upstream.md (decided 2026-11-22) makes J5's envelope the only sender line on a J5 delivery, and we strip upstream's sender line for those messages. EnvelopeFormatter.ts is still how delivery writes metadata, and EnvelopeFormatter.test.ts checks every envelope we write.
    • Mobile doesn't show the raw envelope anymore. feat(mobile): agents' messages read as letters, not envelopes #843 put envelope parsing in packages/client-runtime/src/j5/, which web and mobile share, so agent messages read as letters on both.
    • Web doesn't parse its own copy anymore. The timeline work from the same period folds agent messages into rows named after the sender and never shows the envelope.
    • Adopt upstream senderThreadId on J5 A2A sends #277 (senderThreadId) is done.

    If upstream adds a structured sender field the model actually reads, that's when to revisit. It's already on the watchlist in docs/j5/product/upstream-convergence.md ("a structured sender field the model reads, which could carry J5's envelope instead (D50)"), so this idea won't get lost.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions