agent-host-chat-contributions

Implement and review cross-cutting agent-host chat lifecycle contributions in TypeScript.

10|1|Updated Jul 13, 2026
One-click install
npx skills add https://github.com/KevinHuangIsLearning/shortestpath-ide --skill agent-host-chat-contributions-kevinhuangislearning
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: agent-host-chat-contributions
Source: https://github.com/KevinHuangIsLearning/shortestpath-ide/tree/main/.github/skills/agent-host-chat-contributions
Command: npx skills add https://github.com/KevinHuangIsLearning/shortestpath-ide --skill agent-host-chat-contributions-kevinhuangislearning

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Cross-cutting chat behaviors like admission gating, checkpoint capture, and prompt injection tend to accumulate in large orchestration classes such as AgentSideEffects and AgentService, making them hard to maintain and review. This Skill guides you to build those behaviors as self-contained, ordered, dependency-injected lifecycle contributions instead. ## Core Features & Use Cases - Contribution decision rules: Determine whether a behavior belongs in a contribution or must stay in routing fabric, provider-shaped mapping, or the orchestration classes. - Seven-hook lifecycle model: Implement onIncomingRequest, onTurnEnd, onDidApplyClientAction, onDidDispatchAction, onOutgoingTurn, onHydrateTurns, and onHydrateChat with correct ordering, failure isolation, and memento lifecycle semantics. - Review guidance: Evaluate pull requests that add code to AgentSideEffects or AgentService and enforce the contribution-model boundary. - Use Case: When adding a feature that injects context into outgoing prompts, create a new directory under node/chatContributions/, implement IAgentHostChatContribution with an explicit order, and register it in builtInChatContributions.ts rather than editing AgentSideEffects. ## Quick Start Ask the agent to add a new chat lifecycle behavior, such as attaching metadata to outgoing turns, as a contribution following the agent-host-chat-contributions guidelines.

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 chat lifecycle behavior without modifying AgentSideEffects?▼

Create a directory under node/chatContributions/, implement IAgentHostChatContribution with a unique static id and explicit order, inject services through the constructor after IAgentHostChatContributionContext, and register it once in builtInChatContributions.ts.

When should code stay in AgentSideEffects instead of a contribution?▼

Keep code in AgentSideEffects when it is routing fabric like subagent signal routing or turn-id remapping, a correctness invariant, or provider-shaped mapping such as SDK event mappers and attachment serializers. Convenience is not a valid reason.

Why does onIncomingRequest fail closed while other hooks isolate failures?▼

onIncomingRequest is a synchronous admission gate, so a throw rejects the request with internalError rather than being skipped. Failing open would let requests bypass guards like the read-only or worktree checks, while observer hooks only lose one enrichment.

Should I add a new hook to IAgentHostChatContribution for my feature?▼

Only when no existing payload can express the behavior because it fires at a different moment or from a different source. Prefer adding a discriminant or payload variant to an existing type, such as a new TurnEndReason, over a single-purpose hook.

How do contribution mementos get cleaned up?▼

Chat mementos are evicted when their chat is disposed and session mementos when their session is disposed. For keys with extra segments, call deleteMemento when the value is no longer needed, since setting undefined leaves the map entry alive until disposal.

Why do tests break after extracting behavior into a contribution?▼

Some hand-built test graphs construct AgentSideEffects without calling registerBuiltInChatContributions, so extracted behavior silently stops running. Add the missing registration to mirror production wiring rather than weakening the assertion.