Learning resourcesReviewed · GitHub

GitHub Copilot SDK Session Hooks

GitHub Copilot SDK Session Hooks is a guide for developers customizing Copilot-powered apps, but it does not explain installation or authentication. It introduces callbacks for tool permissions, result transformation, prompt changes, session context, error handling and logging, with examples in TypeScript, Python, Go, .NET and Java.

Researched 14 Nov 2026

In short.

GitHub Copilot SDK Session Hooks is a guide for app developers who need to customize Copilot sessions, but it leaves important integration details unexplained. It maps conversation events to callbacks, shows tool logging and session-start context in TypeScript, Python, Go, .NET and Java quick starts, and adds TypeScript-only patterns for detailed logging, blocking named tools and loading user preferences. The examples include blanket permission approvals; comprehensive access controls, failure behavior, version compatibility and operating costs are not established. No code was executed.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete supplied Session hooks page at [https://docs.github.com/api/article/body?pathname=/en/copilot/how-tos/copilot-sdk/hooks/hooks-overview], including its event table, examples in five languages, invocation context, common patterns and references. Linked pages, SDK package contents and external terms are excluded. No licence text is present in the supplied page. No code was executed; installation, authentication, runtime behavior, compatibility and production operation remain unverified.

The overview

Identity

Session hooks is a GitHub Docs guide to callbacks that let an application intervene at defined points in a Copilot SDK session. The source is [https://docs.github.com/api/article/body?pathname=/en/copilot/how-tos/copilot-sdk/hooks/hooks-overview]. It documents a feature of the SDK rather than providing a standalone application or downloadable hook package.

Assessment

The guide is useful for understanding which session events an application can intercept and how to register basic handlers. Its strongest practical material connects callbacks to concrete tasks: logging calls, denying named tools and adding user preferences.

It is not sufficient by itself for a complete integration. Installation, authentication, detailed callback contracts and operational guarantees are absent. The simple permission examples should be understood as demonstrations of callback behavior, not evidence of comprehensive access control.

Users

The guide suits developers embedding Copilot in an application who need to inspect tool calls, change results, supply session context or respond to errors. Familiarity with asynchronous callbacks and SDK session configuration will help readers follow the examples.

Beginners can use the event table to understand the available intervention points, but will need additional documentation to install the SDK and establish a working session. Developers requiring exact enforcement guarantees will also need more detail than this overview provides.

Capabilities

The overview describes approving, denying or modifying tool calls; transforming tool results; modifying submitted prompts; inspecting or replacing prompts after runtime transformation; adding startup context; handling errors; and recording interactions.

Its event table distinguishes successful tool completion from a failure variant intended for retry guidance and failure logging. Lifecycle hooks cover session start, session end and the top-level agent naturally stopping, when a handler can validate completion or request another turn. Most of these capabilities are described without implementation examples.

Using it

Requirements

The examples require a Copilot SDK integration in the chosen language. They reference @github/copilot-sdk for TypeScript, copilot for Python, github.com/github/copilot-sdk/go for Go, GitHub.Copilot for .NET and com.github.copilot packages for Java.

The page does not specify package versions, minimum language runtimes, supported operating systems, authentication steps, account entitlements or additional runtime dependencies. Those requirements remain unknown from this source.

Mechanism

An application registers hook callbacks in its session configuration. The runtime invokes them around the corresponding events. Every hook receives an invocation context containing sessionId, allowing application code to associate state or logging with a particular session.

The examples return permissionDecision to allow or deny a tool, additionalContext to supplement a session, and null or its language equivalent when a post-tool callback makes no change. The page does not establish hook ordering, timeout behavior or what happens if a callback itself fails.

Setup

The illustrated approach creates a client (CopilotClient in TypeScript, Python, .NET and Java; copilot.NewClient in Go) and attaches handlers while creating a session. The quick starts register pre-tool, post-tool and session-start callbacks. Python and Java explicitly start the client, and their examples also configure permission handlers that approve all requests.

For a complete integration, consult the linked SDK quickstart [https://docs.github.com/en/copilot/get-started/sdk-quickstart] and the guide for the particular hook. Their contents are not included here, so the omitted setup steps and their current requirements are unknown.

Example

The TypeScript blocking example defines BLOCKED_TOOLS as shell, bash and exec. Its onPreToolUse callback checks input.toolName, returns permissionDecision set to deny with an explanatory reason for those names, and allows every other name.

A separate logging pattern prints timestamps, tool names, arguments and results. The session-start pattern loads user preferences and returns them as additionalContext. These are source examples; none was executed, and their runtime behavior was not assessed.

Assessment & evidence

Limitations

The blocking example checks only three exact tool names. It does not demonstrate argument validation, equivalent tools under other names or restrictions on the tools it allows. The logging examples print arguments and results without showing redaction or retention controls.

Failure hooks, prompt transformation, error handling and completion validation receive brief descriptions rather than complete examples. Performance, concurrency behavior, enforcement strength and production operation were not assessed.

Reasoning

The documented event boundaries suggest that hooks can centralize application decisions around tool execution and session behavior. For example, a pre-tool handler provides a place to inspect a proposed call before execution, while a post-tool handler provides a place to alter a returned result.

This is an architectural inference from the described callbacks. The page does not demonstrate that hooks alone enforce an application's complete security requirements or improve model accuracy, reliability or task completion.

Alternatives

The page identifies filesystem hooks loaded from additional startup directories as another way to supply hooks and points to [https://docs.github.com/en/copilot/how-tos/copilot-sdk/features/hooks#repository-hooks-from-additional-directories]. That linked guide is outside the available evidence, so its setup and tradeoffs are unknown.

The source does not compare SDK hooks with other agent frameworks or integration approaches. No comparative recommendation is supported.

Evidence

The evidence consists of the complete supplied GitHub Docs Session hooks page at [https://docs.github.com/api/article/body?pathname=/en/copilot/how-tos/copilot-sdk/hooks/hooks-overview]. It includes the event table, five language quick starts, invocation context, three common patterns and links to more detailed guides.

The descriptions establish what the documentation says, while the snippets establish the patterns it illustrates. Neither constitutes runtime verification. Linked documentation, SDK implementation code and independent measurements are not included.

Access & freshness

Costs

The page provides no SDK pricing, subscription requirements, model-use charges or hook-specific fees. Total operating cost and any required paid entitlement are unknown. The presence of sample code does not establish that the integration is free.

Rights

The supplied page contains no licence text for its documentation, embedded examples or referenced SDK packages. Reuse and redistribution permissions, commercial-use terms and attribution obligations are unknown from this evidence.

Freshness

The supplied page was captured on 14 November 2026 at 19:10:33 UTC. Its text gives no publication date, last-update date or supported SDK version. Compatibility with a particular release and changes after the capture are unknown.

Actions

Start by identifying the event your application needs to intercept, then consult its detailed hook guide and confirm the contract for your installed SDK version. Establish installation, authentication, account requirements and costs before planning an integration.

When implementing permission controls, replace blanket approvals with decisions appropriate to the application's permitted operations. Verify allowed and denied calls, successful and failed tool results, callback errors and session-specific state in your own environment. Decide which arguments and results are appropriate to record before adopting the logging examples.

Evidence for this report

selected-page.txtselected · checked 2026-11-14