Skip to main content

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: