agent-host-chat-contributions
Skill196k starsChanged 17 days agoMITView on GitHub
Build and review cross-cutting agent-host chat behavior through lifecycle contributions. Use when adding turn lifecycle side effects, prompt or context injection, restored-history transformation, protocol-action observation, or when reviewing changes that add code to AgentSideEffects or AgentService.
Trending
More talk lately.about the whole repository
Who's talking about microsoft/vscode
- A Hacker News story“VS Code inserting 'Co-Authored-by Copilot' into commits regardless of usage”Hacker News · May 2, 2026 · 1.5k points
- microsoft/TypeScript“Convert the codebase to modules”GitHub · Nov 2, 2022 · 1.3k reactions
- A Hacker News story“VS Code uses 13% CPU when idle due to blinking cursor rendering”Hacker News · Mar 23, 2017 · 899 points
- A Hacker News story“VS Code Roadmap 2018”Hacker News · Nov 1, 2017 · 360 points
- microsoft/vscode-python“Fix environment-dependent git pre-commit hooks”GitHub · Feb 18, 2020 · 338 reactions
The biggest 5 of 96 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 96
Talked about on Bluesky, Hacker News and GitHub (96 times).
On Bluesky · 48
- Jan 18, 2026Decided to quit being hard headed and just do what everyone else is doing/has done. — @advanced-eschatonics.com12 likes and reposts · 1 reply
- Jul 12, 2026📦 microsoft / vscode ⭐ 187,428 (+52) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Jul 2, 2026📦 microsoft / vscode ⭐ 186,897 (+73) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Nov 2, 2025📦 microsoft / vscode ⭐ 178,121 (+34) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Jan 15, 2025📦 microsoft / vscode ⭐ 166,156 (+43) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
43 more on Bluesky
- Jul 8, 2023📦 microsoft / vscode ⭐ 147,967 (+41) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Apr 5, 2026📦 microsoft / vscode ⭐ 183,440 (+45) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jul 18, 2025Sorry to hear you are hitting this problem! We would love to help you out over at github.com/microsoft/vs... and if you assign your issue… — @eleanor-py.bsky.social2 likes and reposts
- May 21, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 171,731 (+283) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts
- May 20, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 171,513 (+253) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts · 1 reply
- Mar 30, 2025📦 microsoft / vscode ⭐ 169,312 (+41) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Mar 7, 2025📦 microsoft / vscode ⭐ 168,219 (+82) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts
- Feb 12, 2025📦 microsoft / vscode ⭐ 167,217 (+56) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Feb 8, 2025📦 microsoft / vscode ⭐ 167,047 (+49) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jan 24, 2025📦 microsoft / vscode ⭐ 166,533 (+32) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jan 15, 2025📦 microsoft / vscode ⭐ 166,156 (+43) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts
- Sep 1, 2024📦 microsoft / vscode ⭐ 162,015 (+32) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jun 10, 2024📦 microsoft / vscode ⭐ 159,629 (+49) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Aug 26, 2023🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 150,079 (+137) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts · 1 reply
- Nov 7, 2026🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 194,788 (+295) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost · 1 reply
- Nov 6, 2026🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 194,788 (+295) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social1 likes and repost · 1 reply
- Sep 26, 2026📦 microsoft / vscode ⭐ 192,963 (+78) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Sep 26, 2026📦 microsoft / vscode ⭐ 192,963 (+78) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social1 likes and repost
- Jun 25, 2026🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 186,883 (+192) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jun 4, 2026🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 185,791 (+129) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- May 20, 2026📦 microsoft / vscode ⭐ 185,087 (+57) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 16, 2026📦 microsoft / vscode ⭐ 183,924 (+72) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Mar 5, 2026📦 microsoft / vscode ⭐ 182,312 (+76) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Dec 28, 2025📦 microsoft / vscode ⭐ 180,078 (+53) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jul 2, 2025📦 microsoft / vscode ⭐ 174,099 (+53) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- May 24, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 172,520 (+306) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- May 8, 2025📦 microsoft / vscode ⭐ 170,885 (+85) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 11, 2025📦 microsoft / vscode ⭐ 169,887 (+76) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 7, 2025📦 microsoft / vscode ⭐ 169,634 (+51) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Mar 6, 2025📦 microsoft / vscode ⭐ 168,138 (+89) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Feb 16, 2025📦 microsoft / vscode ⭐ 167,406 (+60) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jan 2, 2025lol yeah vscode is kinda wild tbh github.com/microsoft/vscode is the open source project but the versions you get from… — @benharri.org1 likes and repost · 2 replies
- Nov 1, 2024📦 microsoft / vscode ⭐ 163,956 (+52) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jun 18, 2024📦 microsoft / vscode ⭐ 159,805 (+32) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jun 6, 2024📦 microsoft / vscode ⭐ 159,414 (+58) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 11, 2024📦 microsoft / vscode ⭐ 157,765 (+42) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jan 29, 2024📦 microsoft / vscode ⭐ 155,349 (+36) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jan 19, 2024📦 microsoft / vscode ⭐ 155,009 (+57) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Dec 24, 2023📦 microsoft / vscode ⭐ 154,283 (+39) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Mar 17, 2025Something I just realized I want: wikilinks but for any website; kinda like DDG bangs, but for linking to things more easily. Generally… — @blakes.dev0 likes and reposts · 1 reply
- Feb 16, 2024🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 156,140 (+203) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social0 likes and reposts · 1 reply
- Sep 4, 2023🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 150,693 (+178) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social0 likes and reposts · 1 reply
- Aug 26, 2023🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 150,078 (+137) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social0 likes and reposts · 1 reply
On Hacker News · 39
- May 2, 2026VS Code inserting 'Co-Authored-by Copilot' into commits regardless of usage1.5k points · 850 comments
- Mar 23, 2017VS Code uses 13% CPU when idle due to blinking cursor renderingsays it tested it899 points · 760 comments
- Nov 1, 2017VS Code Roadmap 2018360 points · 230 comments
- Dec 19, 2019Santa hat removed from VS Code after complaint243 points · 157 comments
- Apr 18, 2017Show HN: Visual Studio Code for ARM, submitted to core236 points · 83 comments
34 more on Hacker News
- Feb 8, 2026Billing can be bypassed using a combo of subagents with an agent definition213 points · 122 comments
- Oct 27, 2023Microsoft: Require user consent before sending any telemetry128 points · 122 comments
- May 29, 2020Insider Build of VSCode for Windows/ARM64106 points · 79 comments
- May 6, 2026Update on "Co-authored-by: Copilot" in commit messages102 points · 66 comments
- Dec 20, 2019Visual Studio Code repository is open again87 points · 163 comments
- Jun 19, 2018Want free VS Code? Build it from source84 points · 65 comments
- Oct 21, 2020Issue Grooming81 points · 68 comments
- Sep 25, 2026Bug: Border radius has infected VSCode editor80 points · 53 comments
- Mar 19, 2022Visual Studio Code is randomly erasing included header files with latest update75 points · 44 comments
- Sep 3, 2023VSCode Removes Twitter Integration68 points · 31 comments
- Oct 15, 2017New VS Code icon is ugly66 points · 48 comments
- Feb 4, 2023Microsoft mangles VS Code protected properties to prevent UI customization65 points · 28 comments
- Apr 29, 2020VS Code was lost on shutdown with pending update (2018)64 points · 90 comments
- Oct 27, 2025Severe performance penalty found in VSCode rendering loop63 points · 45 comments
- Nov 24, 2020VSCode memory leak issue marked “out-of-scope”62 points · 71 comments
- Feb 16, 2021Visual Studio Code team considers Vim mode depending on upvotes56 points · 27 comments
- Nov 3, 2023VS Code Introduces Floating Windows Support - The Most Requested Feature Ever46 points · 10 comments
- Jan 29, 2019VS Code Roadmap 201933 points · 3 comments
- Apr 21, 2022VS Code Development Process27 points · 3 comments
- Feb 2, 2024VSCode stopped supporting an old glibc version and near EOL users are in trouble23 points · 8 comments
- Jul 11, 2024VSCode won't start on several Mac OS versions, broken over a week16 points · 3 comments
- Nov 15, 2025Markdown files are not openable because of GitHub Copilot11 points · 1 comment
- Mar 17, 2022VSCode creates many empty file with invalid code automatically8 points · 1 comment
- Dec 19, 2019VS Code Issue Tracker Meltdown8 points · 4 comments
- Aug 31, 2023VSCode, have you collaborated with China?7 points
- Mar 15, 2023VS Code Monitors Full Command Line, CPU, Memory Usage of All Processes7 points · 1 comment
- Nov 20, 2024Thing Deleted 3 Months of Work6 points · 4 comments
- Nov 3, 2024VSCode high CPU usage issue affecting macOS6 points
- Oct 9, 2026VSCode silently switches to Microsoft models, ignoring BYO agent configuration5 points · 1 comment
- May 28, 2026VSCode fires up screen recording5 points
- Oct 5, 2025Microsoft Accidentally removes extensions from VSCode Marketplace5 points · 1 comment
- Nov 2, 2023After 7 years, VS Code finally implements preview support for floating windows5 points · 2 comments
- Feb 27, 2020THIS THING DELETED 3 MONTHS OF WORK!!!!5 points · 5 comments
- Dec 20, 2019VS Code is getting flak for removing Santa hat emoji5 points · 7 comments
On GitHub · 9
- Nov 2, 2022Convert the codebase to modules — microsoft/TypeScript1.3k reactions · 56 comments
- Feb 18, 2020Fix environment-dependent git pre-commit hooks — microsoft/vscode-python338 reactions · 57 comments
- Dec 12, 2025Handle writes to non-blocking pty instead of wrapping via Node's tty api — microsoft/node-pty256 reactions · 5 comments
- Oct 31, 2016Add Windows support and first-class Linux support — vercel/hyper160 reactions · 98 comments
- Sep 11, 2024Proposed expandable hover API — microsoft/TypeScript99 reactions · 15 comments
4 more on GitHub
- Dec 22, 2020LSP 3.16.0 — neoclide/coc.nvim64 reactions · 52 comments
- Mar 8, 2021Import statement completions — microsoft/TypeScript47 reactions · 9 comments
- Aug 13, 2017Feature/simple fullscreen mode — electron/electron43 reactions · 8 comments
- May 30, 2018Add support for grid layout — VSCodeVim/Vim37 reactions · 18 comments
In this repository96 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .eslint-plugin-local/AGENTS.mdAGENTS.md
- extensions/copilot/assets/prompts/skills/agent-customization/references/agents.mdAGENTS.md
- extensions/copilot/src/extension/chatSessions/copilotcli/AGENTS.mdAGENTS.md
- extensions/copilot/src/platform/authentication/common/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/common/state/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/node/copilot/prompts/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/test/node/AGENTS.mdAGENTS.md
- src/vs/workbench/contrib/imageCarousel/AGENTS.mdAGENTS.md
- extensions/copilot/.github/copilot-instructions.mdCopilot instructions
- .github/copilot-instructions.mdCopilot instructions
- launchSkill
- github-copilot-upgraderSkill
- launchSkill
- agent-customizationSkill
- chronicleSkill
- create-agentSkill
- create-canvasSkill
- create-hookSkill
- create-instructionsSkill
- create-promptSkill
- create-skillSkill
- initSkill
- migrate-customizationsSkill
- record-videoSkill
- troubleshootSkill
- accessibilitySkill
- agent-host-e2e-testsSkill
- agent-host-logsSkill
- author-contributionsSkill
- auto-perf-optimizeSkill
- azure-pipelinesSkill
- build-champ-triageSkill
- chat-customizations-editorSkill
- chat-perfSkill
- chat-pet-sprite-creationSkill
- ci-artifact-testingSkill
- codenotifySkill
- code-oss-logsSkill
- code-reviewSkill
- component-fixturesSkill
- componentSkill
- context-menusSkill
- cpu-profile-analysisSkill
- customizations-in-the-agent-hostSkill
- design-philosophySkill
- doc-commentsSkill
- endgame-statusSkill
- experimentsSkill
- feature-tryoutsSkill
- feedback-learningSkill
- fix-ci-failuresSkill
- fixissuenoSkill
- flaky-smoke-testsSkill
- heap-snapshot-analysisSkill
- hoverSkill
- integrated-browserSkill
- integration-testsSkill
- issue-groupingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 4 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use the contribution model for a self-contained behavior that crosses an agent-host chat lifecycle boundary.
- Distinctive: line 25
Write a contribution when the behavior answers yes to this test:
- Distinctive: line 33
Do not use a contribution for the following:
- Very specific: line 40
If the answer is "this must route every signal correctly before state changes" or "this differs by SDK," it is not a contribution.
- Very specific: line 93
Add its constructor to the one built-in list with contributions.registerContribution(MarkdownPlanRichLinksContribution).
- Distinctive: line 114
Use explicit orders to preserve a required sequence:
- Very specific: line 128
Never add callbacks or services to IAgentHostChatContributionContext.
- Very specific: line 143
Only wrap a test registration in disposables.add(...) when the class extends Disposable.
- Very specific: line 144
If the collaborator is stateless, prefer a plain function taking ServicesAccessor, invoked through IInstantiationService.invokeFunction, …
- Very specific: line 148
Create keys with createChatMementoKey or createSessionMementoKey in common/agentHostChatContributionsService.ts.
- Very specific: line 174
Add focused dispatcher tests in test/node/chatContributions.test.ts for hook dispatch, ordering, memento eviction, and failure isolation.
- Very specific: line 176
When extracting existing behavior from AgentSideEffects, leave the existing test/node/agentSideEffects.test.ts suite unchanged.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Host Chat Contributions
Use the contribution model for a self-contained behavior that crosses an agent-host chat lifecycle boundary. Read these files before changing the model:
src/vs/platform/agentHost/common/agentHostChatContributionsService.tssrc/vs/platform/agentHost/node/agentHostChatContributionsService.tssrc/vs/platform/agentHost/node/chatContributions/TODO.mdsrc/vs/platform/agentHost/node/chatContributions/builtInChatContributions.ts
The rule that prevents the old failure mode
New cross-cutting features go in contributions, not in
AgentSideEffectsorAgentService.
AgentSideEffects has shed well over 700 lines by extracting seventeen behaviors. Do not put another lifecycle side effect, outgoing-prompt addition, restored-turn enrichment, admission check, or action observer back into either large orchestration class. AgentSideEffects dispatches the lifecycle and retains routing and send mechanics; AgentService owns session lifecycle and invokes hydration and memento eviction. See agentSideEffects.ts and agentService.ts.
This is also a review rule: code added to either file needs a specific reason that it is routing, a correctness invariant, provider-shaped behavior, or a dispatcher call site. "It was convenient to add here" is not a reason.
Decide before you code
Write a contribution when the behavior answers yes to this test:
- Does it react to a lifecycle moment the hooks already name — a turn request asking to proceed, a completed turn, a dispatched action, a turn about to be sent, a restored turn list, or a chat being restored?
- Can an explicitly registered, dependency-injected unit own it without changing protocol routing or provider mapping?
- Does it compose with other behavior in a defined order?
Examples are admission gating, local-command interception, checkpoint and changeset work, queue draining, GitHub-reference attachment, title handling, persisted usage, session input-needed aggregation, session flag persistence, chat drafts, a chat's own config, worktree announcements, unread state, rich-link guidance, and chat-surface guidance. Their directories under node/chatContributions/ are the reference implementations.
Do not use a contribution for the following:
- Subagent signal routing and buffering in
node/agentSideEffects.tsare routing fabric and correctness invariants. - Turn-id remapping in
node/agentSideEffects.tsis also routing fabric. - The three SDK event mappers and three attachment serializers are provider-shaped.
- Provider-shaped overlays applied during restore, such as seeding a draft's model from
IAgent-supplied session metadata in_doRestoreSession. Moving one would push provider metadata intoIHydrationContextfor one consumer.
If the answer is "this must route every signal correctly before state changes" or "this differs by SDK," it is not a contribution. Open work and standing caveats are tracked in node/chatContributions/TODO.md.
Keep the hook surface small
IAgentHostChatContribution has a small set of hooks in common/agentHostChatContributionsService.ts. Only add another method when no existing payload can express the behavior.
The set was once reduced from six to four:
onTurnConsumablebecameonTurnEndwithTurnEndReason.kind === 'localCommand'.onUserMessagebecameonOutgoingTurn.
Prefer adding a discriminant or payload to an existing type, such as a new TurnEndReason variant, over adding a hook. A proposed single-purpose hook with one caller and one implementer is the smell that produced both removals. Do not create an abstraction merely to move one direct call.
The hooks added since clear a specific bar: no existing payload could express them because they fire at a different moment or from a different source, not merely with different data.
onHydrateChatrestores host-owned chat state before a chat enters the catalog.onHydrateTurnsruns lazily, after a provider returns turns, so reusing it would leave a restored peer chat untitled until it was opened.onIncomingRequestgates a turn before it reaches a provider, and can reject it. No observer hook can refuse.onDidDispatchActionobserves server-dispatched and rejected actions, whichonDidApplyClientActionstructurally cannot see.onWillShutdownruns when the host begins a graceful shutdown, before providers stop. Telemetry logged there is delivered by a bounded telemetry flush that the host runs after providers stop, at the same time as its session data flush. Disposal cannot replace it: the desktop host terminates the agent host process after its graceful shutdown, so disposal never runs there.
Adding a { kind: ... } discriminant to an existing hook was considered and rejected for onHydrateChat: the discriminant guidance covers payload variants within one moment, the way TurnEndReason discriminates outcomes of a single turn ending.
Anatomy and registration
Give every contribution its own directory under node/chatContributions/<feature>/. It owns its implementation, helpers, and tests as it grows. A contribution must have:
static readonly id, unique across registrations.- An explicit
order, even when it currently appears independent. - A constructor whose first parameter is
IAgentHostChatContributionContext, followed by injected services. - A single registration in
node/chatContributions/builtInChatContributions.ts.
This is the complete shape of the existing Markdown plan rich-link contribution, adapted from markdownPlanRichLinks/markdownPlanRichLinksContribution.ts:
export class MarkdownPlanRichLinksContribution extends Disposable implements IAgentHostChatContribution {
static readonly id = 'markdownPlanRichLinks';
readonly order = 100;
constructor(
protected readonly _context: IAgentHostChatContributionContext,
@IAgentConfigurationService private readonly _agentConfigService: IAgentConfigurationService,
) {
super();
}
onOutgoingTurn(turn: IOutgoingTurn): ISendContribution | undefined {
return this._agentConfigService.getRootValue(platformRootSchema, AgentHostMarkdownPlanRichLinksEnabledConfigKey)
? { instructions: [createMarkdownPlanRichLinksInstruction(turn.chat)] }
: undefined;
}
}Add its constructor to the one built-in list with contributions.registerContribution(MarkdownPlanRichLinksContribution). That list is activated by activateAgentHostContributions in node/agentHostContributions.ts; do not add a competing registration site. The dispatcher constructs each contribution through IInstantiationService, rejects duplicate ids, and disposes it on unregistration.
The hooks
| Hook | Fires when | Must not assume | Existing example |
onIncomingRequest | A turn request asks to proceed to a provider, before any side effect. Synchronous, and fails closed. | It decides admission, so a throw rejects rather than being skipped. Return accept, handled, or reject; the first non-accept wins and later contributions are not consulted. | localCommand 50, turnAdmission 100 |
onTurnEnd | Any terminal outcome a started turn can reach, plus a request refused before its turn started. | Discriminate rejected from error: the former has no started turn to finalize and no checkpoint to capture. Do not throw. It does not fire for an agent-emitted terminal action arriving with no active turn, because the reducer no-ops for those. | checkpointAndChangeset, queueDrain, githubReferences, sessionTitle, markUnread |
onDidApplyClientAction | A client-dispatched action was applied to host state. | It never sees server-dispatched or rejected actions. Anything it sees definitely reduced. | queueDrain tracks queued senders; sessionTitle persists user title changes. |
onDidDispatchAction | Any action was dispatched and its outcome is known, from any origin. | It also delivers rejected actions that never reduced — check rejectionReason. Implementing this and onDidApplyClientAction together sees every client action twice. | sessionInputNeeded, persistedTurnUsage, chatConfig, sessionFlags |
onOutgoingTurn | Awaited after admission and provider lookup, before the turn is sent. | Rejected turns and noAgent failures never reach it. IOutgoingTurn carries the full Message; contributions can replace its text in order and add instructions, but cannot replace its already-committed attachments, model, agent, origin, or metadata. Prefer the message-text channel for context injection: changing instructions invalidates the provider prompt cache and increases user cost. Do not bypass the send path. | markdownPlanRichLinks, chatSurface, sessionTitle, sideChat |
onHydrateTurns | A provider has returned the complete restored turn list for a chat. | It is not limited to default chats and must return a list for the next stage. Do not assume its input is pristine provider output because earlier contributions may have transformed it. | turnDelegation, persistedTurnUsage, worktreeAnnouncement, sideChat |
onHydrateChat | A chat is being restored, eagerly, before it enters the session catalog. | It runs with no provider — it is a metadata-only read — and before the chat exists, so a chat memento taken here would outlive a failed registration. | sessionTitle, chatDraft, chatConfig |
onWillShutdown | The host begins a graceful shutdown, before providers stop. | It does not run on a crash or a forced kill. The process may exit soon after, so do not depend on async work completing; telemetry logged here is delivered by the host's bounded telemetry flush after providers stop. Do not throw. | sessionSummaryTelemetry logs its pending summaries. |
The call sites are in node/agentSideEffects.ts, node/agentHostTurnStarter.ts, and node/agentService.ts.
Ordering is behavior
order is load-bearing. The dispatcher sorts lower values first; registration order breaks ties only. Ordering is per hook, so the 100-series can be reused for hydration independently of outgoing turns. See node/agentHostChatContributionsService.ts.
Use explicit orders to preserve a required sequence:
LocalCommandContributionis 50 andTurnAdmissionContributionis 100 ononIncomingRequest. That order is load-bearing: local commands were always intercepted before the read-only guard, so/renamestill works in a read-only or archived chat.CheckpointAndChangesetContributionruns at 100 so it captures a checkpoint before later changeset-related work.QueueDrainContributionis 200 andSessionInputNeededContributionis 200.GitHubReferencesContributionandChatSurfaceContributionare 300 where applicable.SessionTitleContributionis 400,MarkUnreadContributionandSideChatContributionare 500,ChatDraftContributionis 600,ChatConfigContributionis 650, andSessionFlagsContributionis 700.
markUnread and sideChat both declare 500 and both implement onTurnEnd, so their relative sequence rests on registration order. Give a new contribution a distinct order rather than joining that tie.
A silent reordering regression already happened. The built-in-sequence regression tests in test/node/chatContributions.test.ts protect the original turn-end, outgoing-turn, and hydration sequences. Add or update those tests when ordering changes intentionally.
Depend on services, not a growing context
Never add callbacks or services to IAgentHostChatContributionContext. It is only contribution identity plus centrally evicted mementos. Coordinate through @Injectable services.
IAgentHostChatContributionHost is intentionally the narrow bridge to AgentSideEffects: it has only hostLaunchKind and sendTurnMessage. It grew to seven members before being cut back to two by promoting collaborators to real services:
IAgentHostSessionTitleControllerIAgentHostProviderServiceIAgentHostTelemetryReporterIAgentHostTurnTrackerIAgentHostToolCallTrackerIAgentHostLocalCommands
IAgentHostWorktreeIsolation is injectable too. "It isn't injectable" was a wrong conclusion caused by service-registration order and later disproved. Trace registration from node/agentHostServices.ts through node/agentHostBootstrap.ts and createAgentServiceComposition in node/agentServiceComposition.ts. Register a real service before the instantiation path constructs contributions; do not smuggle it through the context or host bridge.
Adding a service is not free: roughly six hand-built test ServiceCollections construct AgentSideEffects or call registerBuiltInChatContributions, and each needs the new registration or fails with UNKNOWN service <id>. Two related traps, both hit for real:
- Only wrap a test registration in
disposables.add(...)when the class extendsDisposable; wrapping a plain object throwsd.dispose is not a functionat teardown. - If the collaborator is stateless, prefer a plain function taking
ServicesAccessor, invoked throughIInstantiationService.invokeFunction, and skip DI entirely.node/agentHostTurnStarter.tsis the reference: making it a service bought nothing and cost a registration in every graph.
Mementos have a lifecycle
Create keys with createChatMementoKey or createSessionMementoKey in common/agentHostChatContributionsService.ts. Contexts are contribution-scoped, so identical debug names in two contributions do not collide.
- Chat mementos are evicted when their chat is disposed.
- Session mementos and all supplied chat mementos are evicted when their owning session is disposed.
- Extra key segments are part of the identity. Use them for bounded identities such as a queued message id.
- Call
deleteMementowhen an extra-segment value is no longer needed. Setting its observable toundefinedleaves its map entry alive until chat or session disposal, so a long-lived chat otherwise accumulates one entry per segment value. onHydrateChatruns before its chat is registered, so a chat memento taken there would outlive a registration that then failed. No current contribution does this, but do not be the first without handling it.
queueDrain/queueDrainContribution.ts demonstrates the required delete on queued-message removal and consumption. Central eviction lives in node/agentHostChatContributionsService.ts and is called by node/agentService.ts.
Failure isolation, and the one exception
The dispatcher logs and isolates failures independently for every observer hook:
- A throwing
onTurnEnd,onDidApplyClientAction, oronDidDispatchActioncontribution does not stop later contributions. - A failed
onOutgoingTurncontribution adds no instructions and does not block the send or later contributions. - A failed
onHydrateTurnsoronHydrateChatcontribution deliberately passes the previous value to the next stage. Losing chat history, a title, or a draft is worse than losing one enrichment.
onIncomingRequest inverts this and fails closed. A contribution that throws there rejects the request with internalError at stage validation. That gate is the enforcement behind the UI hiding the composer, so failing open would let a buggy or remote client run work in a session that may no longer have its isolated worktree on disk. Losing one enrichment is survivable; letting a request past a guard is not.
It is also deliberately synchronous, for the same reason: a gate has to decide before the send path performs any await, so the state it reads cannot change between the decision and its effect. Every admission check the host makes today is already synchronous. An async version was tried first and broke three agentSideEffects tests by deferring the read-only guard one microtask past the assertions — which was the design saying the gate belongs before the first await.
Implement normal error handling where it improves the feature, but never depend on a thrown error to control lifecycle flow. The exact dispatch behavior is in node/agentHostChatContributionsService.ts.
Tests and extraction proof
Add focused dispatcher tests in test/node/chatContributions.test.ts for hook dispatch, ordering, memento eviction, and failure isolation. The same file owns the built-in-sequence regression tests.
When extracting existing behavior from AgentSideEffects, leave the existing test/node/agentSideEffects.test.ts suite unchanged. Its passing behavior is the proof that the extraction preserved semantics; test new dispatcher mechanics separately rather than rewriting the old assertions to fit the new structure.
One caveat that has bitten twice: some hand-built test graphs construct AgentSideEffects without calling registerBuiltInChatContributions, so they silently stop exercising behavior the moment it moves into a contribution. When an extraction breaks such a suite, add the missing registration so the graph mirrors production wiring — do not weaken the assertion. The failure means the test was verifying an incomplete graph, not that the extraction was wrong.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

