#744·flue

dispatch() drops host metadata on a kind: "user" delivered message

Author: marvinliu0Created Sep 21, 2026Updated Oct 1, 2026

What happens

dispatch() silently drops any key a host puts on a kind: 'user' delivered message beside kind, body and attachments.

DeliveredUserMessageSchema in src/dispatch.ts declares those three keys, validateDispatchRequest runs parseDeliveredMessage(request.message), and that returns the valibot output. v.object strips unknown keys, so the stripped value is what createDispatchAgentSubmissionInput persists as the submission payload. Nothing warns.

Why a host needs the key

A host that admits a person's message on more than one transport — a web client and a channel bridge, say — needs to record which transport admitted a given submission, and needs that record to survive a restart, because the work runs later in a durable agent.

kind: 'signal' already carries attributes for structured metadata, but a signal is the wrong shape for a 1:1 message: it produces a signal canonical record rather than a user_message, and it changes what the conversation shows. A host that wants the user_message projection has nowhere to put the value.

The submission payload is the natural home, because it is the one thing the runtime already persists and reads back (parseSubmission rebuilds input with JSON.parse of the stored payload).

Why not attributes

renderSignalMessage writes a signal's attributes into the XML tag the model reads, so on a signal attributes is model-visible content. Reusing that name on the user variant for host-private metadata would give one field two meanings depending on kind, and would invite a later change that renders it and leaks host internals into the prompt. A separate name avoids that.

Proposed change

Add an optional, host-private metadata to the user variant, never rendered:

diff
 const DeliveredUserMessageSchema = v.object({
   kind: v.literal("user"),
   body: v.string(),
-  attachments: v.optional(v.array(DeliveredAttachmentSchema))
+  attachments: v.optional(v.array(DeliveredAttachmentSchema)),
+  metadata: v.optional(v.record(v.string(), v.string()))
 });
diff
 type DeliveredMessage = {
   kind: 'user';
   body: string;
   attachments?: DeliveredAttachment[];
+  /** Host-private metadata, persisted with the submission. Never rendered to the model. */
+  metadata?: Record<string, string>;
 } | {

Nothing else needs to change for the value to survive: runPersistedSubmissionInput and buildSubmissionInputRecord read body and attachments alone for a user message, so the model input and the canonical record are unchanged, and parseSubmission returns the parsed payload rather than a re-validated value, so the key round-trips.

Two notes on the shape, in case you prefer a different one:

  • The same field on the signal variant would be symmetric, and would give signals a host-private channel distinct from their model-visible attributes.
  • Putting it on AgentDispatchRequest instead would group it with idempotencyKey and uid, but it would then need to reach the execution context by another route, since those fields do not travel in input.message.

One consequence worth stating: because the persisted payload participates in keyed replay comparison, a host that starts sending metadata under an idempotency key it already used will get a conflict rather than a deduplicated receipt for that one key. That is the existing replay contract, not a new behaviour, but it is the kind of thing worth a line in the docs if you take the field.