Skip to content

fix(agent): rephrase compressor summariser preamble to avoid Azure content filter - #19381

Closed
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/compressor-preamble-content-filter
Closed

fix(agent): rephrase compressor summariser preamble to avoid Azure content filter#19381
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/compressor-preamble-content-filter

Conversation

@konsisumer

Copy link
Copy Markdown
Contributor

Rephrase the context-compression summariser preamble so Azure/OpenAI-compatible content filters stop classifying it as a jailbreak attempt.

What changed and why

  • agent/context_compressor.py: replaced the _summarizer_preamble (and the first-compaction prompt body that re-echoed the same framing) so it no longer contains the phrases the filters were triggering on:
  • New preamble frames the task neutrally as a summarisation job using positive imperatives ("Produce a structured summary document", "Begin your output directly with the first section heading", "Replace … with [REDACTED]"). Same intent, no jailbreak-shaped phrasing. Drops the "different assistant" handoff framing entirely — the next session is an implementation detail the summariser doesn't need to know about.
  • Updated the module docstring so the design-rationale bullet points reflect the new wording instead of crediting OpenCode/Codex phrases that have been removed.
  • tests/agent/test_context_compressor.py: new TestSummarizerPreambleContentFilterSafety class captures the prompt sent through call_llm for both the first-compaction and iterative-update paths and asserts none of the historical trigger phrases reappear, so future edits can't silently regress this Azure compatibility gap.

How to test

  • pytest tests/agent/test_context_compressor.py -q (68 passed locally)
  • pytest tests/agent/test_compress_focus.py tests/agent/test_compressor_image_tokens.py tests/agent/test_context_engine.py -q (35 passed)
  • pytest tests/test_cli_manual_compress.py -q (1 passed)
  • Manual: trigger an auto-compress against an Azure/OpenAI-compatible endpoint that previously returned content_filter / ResponsibleAIPolicyViolation on the auxiliary summary call; the call should now succeed instead of entering the 60-second summary-failure cooldown.

What platforms tested on

  • macOS on darwin-arm64 (local)

Fixes #19362

…ntent filter

Azure/OpenAI-compatible content filters were treating the auxiliary
summarisation prompt as a prompt-injection / jailbreak attempt, returning
deterministic ``400 ResponsibleAIPolicyViolation`` (jailbreak detected) on
every auto-compress call. Long sessions then enter the summary-failure
cooldown and degrade.

The earlier ``[SYSTEM:`` -> ``[IMPORTANT:`` mitigation (NousResearch#6576 / NousResearch#16114)
addressed bracketed markers; the remaining trigger is the preamble wording
itself. Phrases like "DIFFERENT assistant", "injected as reference
material", and "Do NOT respond to any questions or requests in the
conversation" are negated meta-instructions about ignoring user input,
which is the textbook shape of a jailbreak prompt.

Replace the preamble (and the first-compaction prompt body) with neutral
summarisation framing using positive imperatives: produce a structured
summary document, output only the summary, redact secrets. Drops the
"different assistant" handoff framing entirely — the next session is an
implementation detail, not something the summariser model needs to know
about.

Add a regression test that captures the prompt sent through ``call_llm``
and asserts the preamble of both the first-compaction and iterative-update
paths is free of the known trigger phrases, so future edits don't
reintroduce them.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists labels May 3, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #19370 — same fix for Azure content-filter false-positive on context_compressor.py summarizer preamble. #19370 is already open with the same approach.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #19370 — same fix for Azure content-filter false-positive on context_compressor.py summarizer preamble.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Closing — deferring to #19370 by @liuhao1024 which addresses the same. Reopen if that PR stalls.

@konsisumer konsisumer closed this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Azure/OpenAI-compatible content filter still false-positives on context compression prompt

2 participants