Add _meta to UserMessage#168
Merged
Merged
Conversation
Adds an optional `_meta?: Record<string, unknown>` field to `UserMessage` so user messages can carry provider-specific metadata, mirroring the MCP `_meta` convention already used on `MessageAttachmentBase`, `ToolDefinition`, `ToolCallBase`, `UsageInfo`, and `SessionState`. Regenerates the JSON Schema and Go/Kotlin/Rust/Swift/TypeScript clients (`_meta` lands as the idiomatic optional map type in each), updates `docs/guide/state-model.md` to document the new field, and bumps the `Unreleased` section in the spec changelog plus every client CHANGELOG. This is purely additive — existing producers and consumers that ignore `_meta` continue to round-trip messages unchanged. It is also designed to merge cleanly into #155, which renames `UserMessage` → `Message` and will carry the new field forward as `Message._meta`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rust struct literals must exhaustively list every field, so the existing hand-written test fixtures in `crates/ahp/src/reducers.rs` failed to compile after `UserMessage` gained the optional `meta` field. Kotlin, Swift, Go, and TypeScript construction sites pick up the new optional field via their language-default values (`null`, `nil`, zero, omitted) and need no changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an optional _meta field to UserMessage so user messages can carry provider-specific metadata, mirroring the existing MCP _meta convention used elsewhere in the protocol (attachments, tool definitions, tool calls, usage info, session state). The change is purely additive and regenerates all client bindings and schemas.
Changes:
- Add
_meta?: Record<string, unknown>toUserMessageintypes/channels-session/state.tswith JSDoc. - Regenerate JSON schemas and all client bindings (Go, Kotlin, Rust, Swift) plus update Rust reducer test fixtures.
- Update docs and root + per-client CHANGELOGs under
[Unreleased].
Show a summary per file
| File | Description |
|---|---|
| types/channels-session/state.ts | Source-of-truth: adds _meta to UserMessage. |
| schema/{state,notifications,errors,commands,actions}.schema.json | Regenerated schemas pick up optional _meta on UserMessage. |
| docs/guide/state-model.md | Documents _meta on UserMessage and contrasts with attachment _meta. |
| clients/typescript/CHANGELOG.md | Adds [Unreleased] entry. |
| clients/swift/AgentHostProtocol/.../State.generated.swift | Adds meta property, CodingKey, and init parameter. |
| clients/swift/CHANGELOG.md | Adds [Unreleased] entry. |
| clients/rust/crates/ahp-types/src/state.rs | Adds meta: Option<JsonObject> with #[serde(rename = "_meta", …)]. |
| clients/rust/crates/ahp/src/reducers.rs | Updates UserMessage literals in tests with meta: None. |
| clients/rust/CHANGELOG.md | Adds [Unreleased] entry. |
| clients/kotlin/.../State.generated.kt | Adds meta field with @SerialName("_meta"). |
| clients/kotlin/CHANGELOG.md | Adds [Unreleased] entry. |
| clients/go/ahptypes/state.generated.go | Adds Meta map[string]json.RawMessage field. |
| clients/go/CHANGELOG.md | Adds [Unreleased] entry. |
| CHANGELOG.md | Adds root spec [Unreleased] entry. |
Copilot's findings
- Files reviewed: 16/18 changed files
- Comments generated: 0
connor4312
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
_meta?: Record<string, unknown>field toUserMessageso user messages can carry provider-specific metadata, mirroring the MCP_metaconvention already used onMessageAttachmentBase,ToolDefinition,ToolCallBase,UsageInfo, andSessionState.Changes
types/channels-session/state.ts: addUserMessage._metawith JSDoc describing the MCP-aligned semantics.npm run generate._metalands as the idiomatic optional map type in each client:Meta map[string]json.RawMessage \json:"_meta,omitempty"``@SerialName("_meta") val meta: Map<String, JsonElement>? = null#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")] pub meta: Option<JsonObject>public var meta: [String: AnyCodable]?withCodingKeymeta = "_meta"(andinitgains a trailingmeta:parameter defaulting tonil)schema/*.schema.jsonregenerated;UserMessagepicks up an optional_metaobject.docs/guide/state-model.mdshows_metain theUserMessagesnippet and adds a paragraph distinguishing it from the existing attachment-level_metablob.Addedbullet under## [Unreleased]per the AGENTS.md "types/** ripples to every client" rule.Validation
npm run generate— cleannpm run typecheck— cleannpm run lint— cleannpm run verify:release-metadata— passesnpm run verify:changelog— passesnpx tsx --test types/*.test.ts types/version/*.test.ts— 224/224 passing (thenpm run testwrapper otherwise trips the pre-existing c8/yargs incompatibility on Node 26 in this dev env, unrelated to this change)Compatibility
Purely additive. Existing producers and consumers that ignore
_metacontinue to round-trip messages unchanged, so no protocol version bump is required.Coordination with #155
#155 renames
UserMessage→Messageand adds aMessageKinddiscriminant. This PR was deliberately scoped to a single additive field onUserMessageso the new_metafield will carry forward cleanly intoMessage._metawhen #155 lands (or rebases on top of this).(Written by Copilot)