github / github/copilot-cli

preToolUse hook doesn't pass additionalContext to agent

Aperta
#2,585 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
area:plugins
Lingua principale
Shell
Stelle
11.2k
Fork
1.9k
Merge medio
14h 16m
PR unite (30g)
6

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Reproduce the issue with the provided hooks configuration and a tool call, then trace the preToolUse hook handling in the CLI. Verify that the returned additionalContext reaches the agent together with the permission decision and reason, using the documented hook behavior as the completion check.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
shell
Ambito
cli
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.