github / github/copilot-cli

Extension onPostToolUse modifiedResult is not applied to the model's conversation context

Aberta
#3,361 0 comentários 2 reações 0 responsáveis Ver no GitHub
area:plugins
Linguagem predominante
Shell
Estrelas
11.2k
Forks
1.9k
Merge médio
14h 16min
PRs com merge (30d)
6

Descrição

## Summary

When a Copilot CLI extension returns `modifiedResult` from `onPostToolUse`, the modified text appears in the TUI tool-result preview line but is **not** applied to the model's conversation context. The model sees and responds with the original unmodified tool result.

## Reproduction

Minimal single-file extension (`.github/extensions/repro/extension.mjs`):

```js
import { joinSession } from "@github/copilot-sdk/extension";

joinSession({
tools: [
{
name: "say_hello",
description: "Returns a greeting message",
parameters: { type: "object", properties: {} },
async handler() {
return "ORIGINAL: The tool returned this text.";
},
},
],
hooks: {
async onPostToolUse(input) {
if (input.toolName !== "say_hello") return {};
return {
modifiedResult: {
textResultForLlm: "MODIFIED: The hook replaced the result with this text.",
resultType: "success",
},
};
},
},
});
```

### Steps

1. Place the above in a git repo under `.github/extensions/repro/extension.mjs`
2. Run `copilot --allow-all` from the repo root
3. Ask: "call say_hello and tell me exactly what it returned"

### Expected

The model reports: `MODIFIED: The hook replaced the result with this text.`

### Actual

The TUI tool-result preview correctly shows:
```
● say_hello
└ MODIFIED: The hook replaced the result with this text.
```

But the model responds with: `ORIGINAL: The tool returned this text.`

## Observations

- The hook **does** fire — stderr logging in the hook confirms execution.
- The TUI preview line shows the **modified** text.
- The model responds with the **original** text.
- This suggests the hook's `modifiedResult` is applied to the display layer but not to the model's message history.

## Impact

Any extension relying on `onPostToolUse` + `modifiedResult` for result transformation (sanitization, redaction, enrichment) is silently broken. The hook appears to work from the TUI, but the model operates on original data.

## Environment

- Copilot CLI 1.0.49-1
- Windows 11

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Start with the reproduction in .github/extensions/repro/extension.mjs and trace onPostToolUse handling of modifiedResult from the hook through the tool-result preview and model conversation context. Verify where the original result enters message history. Done means the model reports the modified text while the TUI preview remains correct.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript
Domínio
cli
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
48/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.