agent-host-chat-contributions

Guide implementation and review of cross-cutting agent-host chat lifecycle contributions.

190k|41.9k|Updated Sep 3, 2015
One-click install
npx skills add https://github.com/microsoft/vscode --skill agent-host-chat-contributions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agent-host-chat-contributions
Source: https://github.com/microsoft/vscode/tree/main/.github/skills/agent-host-chat-contributions
Command: npx skills add https://github.com/microsoft/vscode --skill agent-host-chat-contributions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers adding new cross-cutting behaviors to VS Code's agent-host chat lifecycle often place them directly in AgentSideEffects or AgentService, which bloats these orchestration classes and breaks established architectural boundaries. This Skill enforces the contribution model so new behaviors live in self-contained, dependency-injected units with explicit ordering and clear hook semantics.

Core Features & Use Cases

  • Decision Framework: Provides a yes/no test to determine whether a new behavior belongs as a contribution versus routing fabric or provider-shaped code.
  • Hook Reference: Documents the seven IAgentHostChatContribution hooks, their firing moments, ordering constraints, and failure-isolation rules.
  • Anatomy & Registration: Specifies the required shape of a contribution (unique id, explicit order, context-first constructor) and the single registration site in builtInChatContributions.ts.
  • Review Rule: Flags code added to AgentSideEffects or AgentService that lacks a routing, correctness, provider, or dispatcher justification.
  • Use Case: When reviewing a pull request that adds a new lifecycle side effect, prompt injection, restored-history transformation, or action observer, apply this Skill to verify the contribution model is followed and ordering tests are updated.

Quick Start

Review the proposed change against the agent-host chat contributions model and confirm the new behavior is registered as a contribution with explicit ordering.

Frequently Asked Questions about agent-host-chat-contributions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new cross-cutting behavior to the agent-host chat lifecycle?

Create a new directory under `node/chatContributions/<feature>/` with a class implementing `IAgentHostChatContribution`. Give it a unique static id, an explicit order, and a constructor whose first parameter is `IAgentHostChatContributionContext`. Register it once in `builtInChatContributions.ts`.

What is the difference between a contribution and routing fabric in AgentSideEffects?

Contributions react to lifecycle moments through named hooks and can be dependency-injected without changing protocol routing. Routing fabric like subagent signal buffering and turn-id remapping must stay in `AgentSideEffects` because it routes every signal correctly before state changes.

When should I add a new hook to IAgentHostChatContribution?

Only add a hook when no existing payload can express the behavior because it fires at a different moment or from a different source. Prefer adding a discriminant like a new `TurnEndReason` variant over introducing a single-purpose hook with one caller.

Why does onIncomingRequest fail closed while other hooks isolate failures?

`onIncomingRequest` is the admission gate that enforces the read-only guard and hides the composer in the UI. A throwing contribution there rejects the request with `internalError` at the validation stage, preventing work in sessions that may have lost their isolated worktree.

How do I handle memento cleanup for chat contributions?

Use `createChatMementoKey` or `createSessionMementoKey` from `agentHostChatContributionsService.ts`. Call `deleteMemento` when an extra-segment value is no longer needed, because setting its observable to undefined leaves the map entry alive until chat or session disposal.

What ordering constraints apply to chat contributions?

Lower order values run first, with registration order breaking ties. LocalCommand is 50 and TurnAdmission is 100 on `onIncomingRequest` so local commands intercept before the read-only guard. Update the built-in-sequence regression tests in `chatContributions.test.ts` when changing order intentionally.