Answer: To audit, combine onPreToolUse, onPostToolUse, and the session lifecycle hooks to build a complete audit trail that records every action the agent takes. To redact secrets from tool results, use an onPostToolUse hook that replaces matches of SECRET_PATTERNS with "[REDACTED]" and returns { modifiedResult: redacted }. Status: Confirmed Entry: tool/github-copilot/privacy-and-data/hooks-audit-redact Revision: 3 Digest: sha256:c963ff707f0df2e4 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:28:02Z Last changed: 2026-11-18T13:03:27Z (secret patterns: — → /(?:api[_-]?key|token|secret|password)\s*[:=]\s*["']?[\w\-\.]+["']?/gi) Last verified: 2026-11-20T13:08:21Z Next check: 2026-11-21T13:08:21Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of audit hooks | onPreToolUse , onPostToolUse , and the session lifecycle hooks | [1] | 2026-11-20 redaction hook | onPostToolUse | [1] | 2026-11-20 redaction replacement | [REDACTED] | [1] | 2026-11-20 modified result return | { modifiedResult : redacted } | [1] | 2026-11-20 secret patterns | /(?:api[_-]?key|token|secret|password)\s*[:=]\s*["']?[\w\-\.]+["']?/gi | [1] | 2026-11-20 Sources: [1] GitHub. "Working with hooks - GitHub Docs". https://docs.github.com/en/copilot/how-tos/copilot-sdk/features/hooks Role: primary. Accessed: 2026-11-20T13:08:21Z Quote: "Combine onPreToolUse , onPostToolUse , and the session lifecycle hooks to build a complete audit trail" (Supports: audit hooks) Quote: "onPostToolUse : async (input) => {" (Supports: redaction hook) Quote: "redacted = redacted. replace (pattern, "[REDACTED]" );" (Supports: redaction replacement) Quote: "return redacted !== input. toolResult ? { modifiedResult : redacted } : null ;" (Supports: modified result return) Quote: "/(?:api[_-]?key|token|secret|password)\s*[:=]\s*["']?[\w\-\.]+["']?/gi" (Supports: secret patterns) Snapshot SHA-256: d0da331e57d20d0992bf99178fb6a23d61ea14315aadbc1f93dcec26b7bd5d7f (captured 2026-11-18T13:03:24Z) 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:03:27Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:08:21Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:08:21Z Last attempt: 2026-11-20T13:08:21Z Notes and limitations: Extracted automatically from a single official source (section "Use case: auditing and compliance"). Related: https://latestn.com/tool/github-copilot/privacy-and-data/integration-data-usage How does GitHub Copilot handle data usage with integrations? https://latestn.com/tool/github-copilot/privacy-and-data/log-prompts-for-auditing How do I log Copilot CLI prompts for auditing? https://latestn.com/tool/github-copilot/privacy-and-data/manage-copilot-memory-retention How do I manage GitHub Copilot Memory retention for an enterprise or organization? https://latestn.com/tool/github-copilot/privacy-and-data/delete-session-data How do I delete GitHub Copilot CLI session data? https://latestn.com/tool/github-copilot/privacy-and-data/disable-telemetry How do I disable client-side telemetry in GitHub Copilot CLI? https://latestn.com/tool/github-copilot/privacy-and-data/export-delete-user-preferences How do I export or delete user-level preferences for GitHub Copilot Memory in an enterprise or organization? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-18T13:03:27Z | changed | secret patterns: — → /(?:api[_-]?key|token|secret|password)\s*[:=]\s*["']?[\w\-\.]+["']?/gi | [1] 2026-11-18T13:03:27Z | changed | redaction replacement: — → [REDACTED] | [1] 2026-11-18T13:03:27Z | changed | modified result return: modifiedResult → { modifiedResult : redacted } | [1] 2026-11-18T13:03:27Z | changed | redaction placeholder: [REDACTED] → — | [1] 2026-11-18T13:03:27Z | changed | audit hooks: onPreToolUse → onPreToolUse , onPostToolUse , and the session lifecycle hooks | [1] 2026-11-16T12:52:16Z | changed | modified result return: { modifiedResult : redacted } → modifiedResult | [1] 2026-11-13T03:28:02Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/github-copilot/privacy-and-data/hooks-audit-redact/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/hooks-audit-redact POST: https://latestn.com/dispute/tool/github-copilot/privacy-and-data/hooks-audit-redact with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/github-copilot/privacy-and-data/hooks-audit-redact?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I set up GitHub Copilot SDK hooks for auditing and redacting secrets? Revision 3, last verified 2026-11-20T13:08:21Z. https://latestn.com/tool/github-copilot/privacy-and-data/hooks-audit-redact (accessed 2026-11-21T10:00:13Z). @misc{LatestN_tool_github_copilot_privacy_and_data_hooks_audit_redact_r3, title = {How do I set up GitHub Copilot SDK hooks for auditing and redacting secrets?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/github-copilot/privacy-and-data/hooks-audit-redact}}, note = {Revision 3; digest sha256:c963ff707f0df2e4; last verified 2026-11-20T13:08:21Z; accessed 2026-11-21T10:00:13Z} } 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/hooks-audit-redact