design-ahp-protocol
Design or review Agent Host Protocol commands, actions, state, errors, reducers, schemas, code generation, versioning, compatibility, and multi-client invariants. Use when changing the AHP contract or assessing a protocol-level design, not when implementing only one host, client, or test suite.
- License 许可
- MIT
- 最近更新
- 2026-11-04
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- design-ahp-protocol
- license
- MIT
- description
- Design or review Agent Host Protocol commands, actions, state, errors, reducers, schemas, code generation, versioning, compatibility, and multi-client invariants. Use when changing the AHP contract or assessing a protocol-level design, not when implementing only one host, client, or test suite.
02 资源文件 5
- 资产文件assets/template-api-docs.md5.5 KB
- 资产文件assets/template-quick-start.md2.5 KB
- 资产文件assets/template-tutorial.md4.7 KB
- 参考文档references/adhd-patterns.md7.2 KB
- 参考文档references/checklist.md4.0 KB
03 SKILL.md 正文
Design AHP Protocol
Use this skill for a change to the AHP contract itself: a command, action, channel state shape, error, reducer rule, schema, generated binding, version rule, or interoperability invariant.
Use this / use another skill
| Use this skill | Use another skill |
|---|---|
| The requested outcome changes what AHP peers may send, receive, reduce, or negotiate. | Use build-ahp-host for an implementation-only server concern. |
| You need to evaluate compatibility, capability gating, or cross-language code generation. | Use build-ahp-client for consuming an established contract in an app or SDK client. |
| You are defining the observable contract that tests must enforce. | Use test-ahp-conformance to implement black-box probes for an established contract. |
If a task includes design and implementation, settle the contract and its observable invariants here first, then activate the implementation skill for the code-owning portion.
Establish the current authority
- Identify the protocol version and branch actually targeted; do not infer shapes from an old sample, package, or blog post.
- Locate the protocol source in the workspace. Read its
types/, canonical channel reducers, schemas,docs/specification/,docs/guide/, version registry, and the relevant Rust and TypeScript SDK bindings. - If the source is not present, use the released schemas and documentation in
microsoft/agent-host-protocol; state which revision or release informed the decision. Do not hard-code a local sibling-repository path. - Inspect nearby prior art, existing test cases, generated-file conventions, and release/versioning instructions before proposing a new shape.
- Separate normative AHP behavior from profile, host, or sample policy. A bounded replay log, a selected persistence engine, or an unsupported feature in one host is not automatically a protocol requirement.
Model the change before editing
Write a compact contract table:
| Question | Decide explicitly |
|---|---|
| Scope | Channel URI, command/notification, action, state fields, and ownership |
| Direction | Client request/notification, server response/notification, or both |
| Reducer | Pure state transition, idempotence, replacement/merge/append behavior |
| Ordering | serverSeq, origin echo/rejection, and ordering with related actions |
| Failure | JSON-RPC versus rejected action, error code/data, recoverability |
| Compatibility | Version introduction, capability gate, old-peer behavior, omission rules |
Actions are state mutations, not a substitute for vague side effects. Route an inner action by its envelope's channel; retain action fields that are intrinsic to the action. Define who assigns identifiers and how multiple clients converge.
For client-dispatchable actions, specify authoritative echo and rejection semantics. A client may optimistically reduce an action, but it must rebase pending work on server-authoritative envelopes and undo a rejected prediction.
State and reducer discipline
- Start from the canonical state and action discriminated unions, not a handwritten partial copy.
- Make reducers pure, exhaustive, and immutable. Keep I/O, transport, model calls, and persistence outside reducer code.
- Define snapshot and action equivalence: reducing a snapshot followed by ordered actions must reach the same observable state for all subscribers.
- State which fields are complete replacements, patches, keyed upserts, or append-only histories. Define unknown IDs, duplicate IDs, and terminal-state handling.
- Do not let a session catalog summary silently become live session state; use the current channel definitions and typed snapshots.
Versioning and generated artifacts
- Classify the change as additive, breaking, or clarification under the protocol's current SemVer and stability policy.
- For additive behavior, decide whether a capability is needed before it becomes baseline. Older peers must safely ignore behavior they do not know.
- Ensure negotiation selects one offered version for the whole connection; never design per-message renegotiation.
- Change canonical types, schemas, version registry, and fixtures first. Run the repository's generators and commit their outputs only when that repository tracks them. Never hand-edit generated bindings as the source of truth.
- Update normative documentation, compatibility notes, and changelog material required by the repository's release process.
Validate the contract
Test the smallest affected layer first: schema/type checks and reducer fixtures. Then run generated-binding checks and cross-client or wire tests relevant to the change. Include:
- valid and malformed shapes;
- ordering and repeated delivery;
- old/new compatible peers and unsupported negotiation;
- two clients racing or observing the same resource;
- snapshots versus action replay and rejection reconciliation.
Stop when the types, schema, canonical reducer behavior, generated SDKs, and normative docs agree. Record intentional scope and non-goals, especially features left capability-gated or profile-specific.
04 同仓库更多 Skills
test-ahp-conformance
Create or review black-box Agent Host Protocol conformance tests, including deterministic model fixtures, lifecycle and error cases, multi-client and restart coverage, bounded timeouts, and CLI/HTML reports with optional JSON results. Use for observable interoperability testing, not for changing protocol design or implementing host/client production code.
build-ahp-host
Implement or review an Agent Host Protocol host or server, including JSON-RPC transport routing, subscriptions, serverSeq and reconnect, durable state, cancellation, concurrency, model adapters, and explicit unsupported behavior. Use for host architecture and server behavior, not for changing the AHP contract or building a client UI.
build-ahp-client
Implement or review an SDK-backed Agent Host Protocol client application, including initialization, subscriptions, immutable reducer state, reconnect cleanup, multi-host behavior, and UI-friendly projections. Use for browser, TypeScript, desktop, or other client consumers, not for host internals or protocol contract changes.