Skip to content

fix(security): redact secrets from context compaction (PR #9200) - #13228

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-eaac5e6d
Apr 20, 2026
Merged

fix(security): redact secrets from context compaction (PR #9200)#13228
teknium1 merged 1 commit into
mainfrom
hermes/hermes-eaac5e6d

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Redacts secrets before context compaction so API keys stop leaking into summaries.

Cherry-picked from PR #9200 by @entropidelic onto current main, merge conflicts resolved (language instruction preserved alongside new redaction instructions).

Changes

  • agent/context_compressor.py: +17/-6 — three-layer defense:
    1. Input: redact_sensitive_text() on message content and tool call arguments in _serialize_for_summary()
    2. Prompt: NEVER include secrets instruction in summarizer preamble, template Critical Context, and focus topic
    3. Output: redact_sensitive_text() on summary result and _previous_summary

Tests from the original PR were not included (vacuously true assertions — test data contained pre-redacted values).

Closes #9200.

Three-layer defense against secrets leaking into compaction summaries:
1. Input redaction: redact_sensitive_text() on message content and tool
   call arguments in _serialize_for_summary() before sending to summarizer
2. Prompt instructions: NEVER include API keys/tokens/passwords in the
   summarizer preamble, template Critical Context section, and focus topic
3. Output redaction: redact_sensitive_text() on the summary output and
   _previous_summary for iterative updates

Reuses existing agent/redact.py patterns (sk-*, ghp_*, key=value, etc).

Cherry-picked from PR #9200 by @entropidelic.
@teknium1
teknium1 merged commit 3368814 into main Apr 20, 2026
5 of 7 checks passed
@teknium1
teknium1 deleted the hermes/hermes-eaac5e6d branch April 20, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants