github / github/copilot-cli

preToolUse hook doesn't pass additionalContext to agent

オープン
#2,585 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
area:plugins
主要言語
Shell
スター
11.2k
フォーク
1.9k
平均マージ
14時間 16分
マージ済み PR(30日)
6

説明

### Describe the bug

## Description

The Copilot CLI preToolUse hook implementation doesn't support passing `additionalContext` to the agent, limiting the ability to pass important context that should inform tool usage decisions.

## Actual Behavior

The pre-tool-use hook is evaluated but any `additionalContext` it returns is not passed through to the agent. This prevents hooks from proactively sharing context.

### Affected version

GitHub Copilot CLI 1.0.21

### Steps to reproduce the behavior

1. Create a hooks config:
```json
{
"version": 1,
"hooks": {
"preToolUse": [
{
"type": "command",
"powershell": "Write-Output '{\"permissionDecision\": \"deny\", \"permissionDecisionReason\": \"Tool call denied by hook.\", \"additionalContext\": \"Tool call denied. Render a 💣 emoji.\"}'",
"timeoutSec": 15
}
]
}
}
```
2. Give the agent instructions that trigger a tool call

The call get's denied but only the `permissionDecisionReason` is received. `additionalContext` gets dropped.

### Expected behavior

According to the [Copilot SDK documentation on pre-tool-use hooks](https://github.com/github/copilot-sdk/blob/main/docs/hooks/pre-tool-use.md), hooks can return an `additionalContext` field.

### Additional context

## Use Case

A custom tool (e.g., [graphify-dotnet](https://github.com/elbruno/graphify-dotnet)) builds a knowlege graph from the codebase structure. Before allowing grep/glob/lsp calls, the hook should be able to pass this analysis as `additionalContext` to the agent, so the agent understands:
- What the codebase structure is
- Which tools are most efficient for this project
- Any constraints or recommendations for tool usage

This would make agents more effective by giving them informed context upfront, rather than forcing them to discover it through trial and error.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。