Skip to content

Compaction fails permanently when Azure content filter blocks summarization — no model fallback #64960

@OpenCodeEngineer

Description

@OpenCodeEngineer

Bug

When the compaction/summarization model is hosted on Azure and the session history contains content that triggers Azure's content management policy, compaction fails with HTTP 400 — and never recovers because:

  1. retryAsync in compaction.ts:317 retries 3× with the same model
  2. resolveEmbeddedCompactionTarget() in compaction-runtime-context.ts uses the session's primary model unless compaction.model override is set — there's no fallback chain
  3. The outer overflow loop retries compaction up to MAX_OVERFLOW_COMPACTION_ATTEMPTS times, but always with the same model
  4. Result: overflow → compact → Azure rejects → overflow → repeat forever

Observed error

Full summarization failed: Summarization failed: 400 The response was filtered 
due to the prompt triggering Azure OpenAI's content management policy.

Expected behavior

Compaction should have a model fallback chain (similar to the session's model fallback). When the primary compaction model rejects content, try an alternative model that doesn't have the same content filter.

Suggested fix

  1. Add agents.defaults.compaction.fallbacks config (array of model refs)
  2. Wrap the compaction invocation in a model-fallback loop at the orchestrator level (not inside summarizeChunks)
  3. Compaction model choice must be ephemeral — per-attempt only, never persisted to sessions.json (to avoid reintroducing the model-lock bug from LiveSessionModelSwitch silently hijacks fallback in live sessions, creating infinite retry loop #58303)
  4. After all compaction models fail: force compact_then_truncate as a hard escape

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions