Use hooks
Detailed API reference for each session hook in the GitHub Copilot SDK.
Error handling hook
The onErrorOccurred hook is called when errors occur during session execution. Use it to:
Session hooks
Hooks allow you to intercept and customize the behavior of Copilot sessions at key points in the conversation lifecycle. Use hooks to:
Post-tool use hook
The onPostToolUse hook is called after a tool executes successfully. Use it to:
Pre-tool use hook
The onPreToolUse hook is called before a tool executes. Use it to:
Session lifecycle hooks
Session lifecycle hooks let you respond to session start and end events. Use them to:
User prompt submitted hook
The onUserPromptSubmitted hook is called when a user submits a message. Use it to:
User prompt transformed hook
The userPromptTransformed hook runs after the runtime adds generated context to a submitted prompt, but before the resulting content is persisted to session history or sent to the model.