Answer: You define an onPostToolUse hook in the session's hooks that checks if input.toolResult is a string, applies regex patterns for sensitive data (API keys, passwords, secrets) replacing matches with "[REDACTED]", and returns { modifiedResult: redacted } when the result changed. Status: Confirmed Entry: tool/github-copilot/privacy-and-data/redact-sensitive-data-hook Revision: 2 Digest: sha256:a1af97a65ab1cb5b (changes whenever the content changes) Timeline: Created: 2026-11-13T03:28:33Z Last changed: 2026-11-17T13:27:10Z (Secret pattern: — → /secret["\s:=]+["']?[\w-]+["']?/gi) Last verified: 2026-11-20T13:09:01Z Next check: 2026-11-21T13:09:01Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Hook name | onPostToolUse | [1] | 2026-11-20 Replacement text | [REDACTED] | [1] | 2026-11-20 Return value | modifiedResult | [1] | 2026-11-20 API key pattern | /api[_-]?key["\s:=]+["']?[\w-]+["']?/gi | [1] | 2026-11-20 Password pattern | /password["\s:=]+["']?[\w-]+["']?/gi | [1] | 2026-11-20 Secret pattern | /secret["\s:=]+["']?[\w-]+["']?/gi | [1] | 2026-11-20 Sources: [1] GitHub. "Post-tool use hook - GitHub Docs". https://docs.github.com/en/copilot/how-tos/copilot-sdk/hooks/post-tool-use Role: primary. Accessed: 2026-11-20T13:09:01Z Quote: "onPostToolUse : async (input) => {" (Supports: Hook name) Quote: "redacted. replace (pattern, "[REDACTED]" );" (Supports: Replacement text) Quote: "return { modifiedResult : redacted };" (Supports: Return value) Quote: "/api[_-]?key["\s:=]+["']?[\w-]+["']?/gi" (Supports: API key pattern) Quote: "/password["\s:=]+["']?[\w-]+["']?/gi" (Supports: Password pattern) Quote: "/secret["\s:=]+["']?[\w-]+["']?/gi" (Supports: Secret pattern) Snapshot SHA-256: a9b0c655b6d7d5c6fbe2f77c6ee190376aaa793d24d74d9b27d816c352e48ab4 (captured 2026-11-18T13:04:13Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-18T13:04:13Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:09:01Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:09:01Z Last attempt: 2026-11-20T13:09:01Z Notes and limitations: Extracted automatically from a single official source (section "Redact sensitive data"). Related: https://latestn.com/tool/github-copilot/privacy-and-data/responsible-use-inline-suggestions What are the responsible use considerations for GitHub Copilot inline suggestions? https://latestn.com/tool/github-copilot/privacy-and-data/session-data-location-access Where is GitHub Copilot session data stored and who can access it? https://latestn.com/tool/github-copilot/privacy-and-data/what-is-persisted What data does the GitHub Copilot SDK persist across sessions? https://latestn.com/tool/github-copilot/privacy-and-data/opentelemetry-data-sent What data does GitHub Copilot send when OpenTelemetry is enabled? https://latestn.com/tool/github-copilot/privacy-and-data/protect-sensitive-info-from-agent How do I protect sensitive information from being accessed by the GitHub Copilot cloud agent? https://latestn.com/tool/github-copilot/privacy-and-data/public-code-matches How does GitHub Copilot handle references to matching public code? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-17T13:27:10Z | changed | Secret pattern: — → /secret["\s:=]+["']?[\w-]+["']?/gi | [1] 2026-11-17T13:27:10Z | changed | Password pattern: — → /password["\s:=]+["']?[\w-]+["']?/gi | [1] 2026-11-17T13:27:10Z | changed | API key pattern: — → /api[_-]?key["\s:=]+["']?[\w-]+["']?/gi | [1] 2026-11-17T13:27:10Z | changed | Return value: — → modifiedResult | [1] 2026-11-17T13:27:10Z | changed | Replacement text: — → [REDACTED] | [1] 2026-11-17T13:27:10Z | changed | Hook name: — → onPostToolUse | [1] 2026-11-17T13:27:10Z | changed | sensitive pattern 3: /secret["\s:=]+["']?[\w-]+["']?/gi → — | [1] 2026-11-17T13:27:10Z | changed | sensitive pattern 2: /password["\s:=]+["']?[\w-]+["']?/gi → — | [1] 2026-11-17T13:27:10Z | changed | sensitive pattern 1: /api[_-]?key["\s:=]+["']?[\w-]+["']?/gi → — | [1] 2026-11-17T13:27:10Z | changed | return value: modifiedResult → — | [1] 2026-11-17T13:27:10Z | changed | replacement text: [REDACTED] → — | [1] 2026-11-17T13:27:10Z | changed | hook name: onPostToolUse → — | [1] 2026-11-13T03:28:33Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/github-copilot/privacy-and-data/redact-sensitive-data-hook/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/github-copilot/privacy-and-data/redact-sensitive-data-hook POST: https://latestn.com/dispute/tool/github-copilot/privacy-and-data/redact-sensitive-data-hook with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/github-copilot/privacy-and-data/redact-sensitive-data-hook?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I redact sensitive data from tool results using a GitHub Copilot post-tool use hook? Revision 2, last verified 2026-11-20T13:09:01Z. https://latestn.com/tool/github-copilot/privacy-and-data/redact-sensitive-data-hook (accessed 2026-11-21T09:54:18Z). @misc{LatestN_tool_github_copilot_privacy_and_data_redact_sensitive_data_hook_r2, title = {How do I redact sensitive data from tool results using a GitHub Copilot post-tool use hook?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/github-copilot/privacy-and-data/redact-sensitive-data-hook}}, note = {Revision 2; digest sha256:a1af97a65ab1cb5b; last verified 2026-11-20T13:09:01Z; accessed 2026-11-21T09:54:18Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/github-copilot/privacy-and-data/redact-sensitive-data-hook