You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extension onPostToolUse modifiedResult is not applied to the model's conversation context #3361
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.
import{joinSession}from"@github/copilot-sdk/extension";joinSession({tools: [{name: "say_hello",description: "Returns a greeting message",parameters: {type: "object",properties: {}},asynchandler(){return"ORIGINAL: The tool returned this text.";},},],hooks: {asynconPostToolUse(input){if(input.toolName!=="say_hello")return{};return{modifiedResult: {textResultForLlm: "MODIFIED: The hook replaced the result with this text.",resultType: "success",},};},},});
Steps
Place the above in a git repo under .github/extensions/repro/extension.mjs
Run copilot --allow-all from the repo root
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.
A plain string in modifiedResult is ignored, and the model still gets the original result. What does work is returning the CLI's own result object with its text replaced. The toolResult passed to the hook looks like this:
Verified live: the model then quotes the replacement and never the original. SuppressOutput and AdditionalContext had no visible effect either way. This relies on undocumented internals, so a fix that honours a plain string, or documentation of the expected shape, would still be appreciated.
Thanks for the minimal repro. A modifiedResult returned from onPostToolUse is now applied to the tool result the model sees, not just the timeline preview (confirmed above on CLI v1.0.98), so please update to the latest version. Note that modifiedResult needs to be a tool result object, for example { textResultForLlm: "...", resultType: "success" } as in your repro; a plain string isn't applied, so feel free to open a separate request if you'd like strings accepted. If an object-form modifiedResult still doesn't reach the model on the latest version, please reopen.
Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.
Activity
sharpSteff commentedon Oct 16, 2026
I stumbled also over this issue, and got a workaround
Workaround (CLI 1.0.98, GitHub.Copilot.SDK 1.0.11, .NET)
A plain string in
modifiedResultis ignored, and the model still gets the original result. What does work is returning the CLI's own result object with its text replaced. ThetoolResultpassed to the hook looks like this:{ "textResultForLlm": "...", "binaryResultsForLlm": [], "resultType": "success", "sessionLog": "...", ... }Clone that object, overwrite
textResultForLlm(andsessionLog, so the original isn't kept), and return it asmodifiedResult:Verified live: the model then quotes the replacement and never the original.
SuppressOutputandAdditionalContexthad no visible effect either way. This relies on undocumented internals, so a fix that honours a plain string, or documentation of the expected shape, would still be appreciated.patniko commentedon Oct 26, 2026
Thanks for the minimal repro. A
modifiedResultreturned fromonPostToolUseis now applied to the tool result the model sees, not just the timeline preview (confirmed above on CLI v1.0.98), so please update to the latest version. Note thatmodifiedResultneeds to be a tool result object, for example{ textResultForLlm: "...", resultType: "success" }as in your repro; a plain string isn't applied, so feel free to open a separate request if you'd like strings accepted. If an object-formmodifiedResultstill doesn't reach the model on the latest version, please reopen.Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.