Join our Newsletter — 33% off our NHI Course
Home› Glossary› AI Security› Compaction
AI Security

Compaction

← Back to Glossary
By NHI Mgmt Group Updated October 31, 2026 Domain: AI Security

Compaction is the process of reducing long conversation history into a shorter representation the model can still use. Good compaction preserves task intent, open decisions, and operational constraints, while poor compaction can erase the details needed for safe or correct action.

What compaction is doing under the hood

Compaction is an information-preservation step, not a simple summary. Its job is to compress a growing interaction history into a smaller state that still supports the next decision, tool call, or answer. The best compaction retains the task objective, the current plan, explicit constraints, and any unresolved choices that still matter.

That makes compaction different from generic note-taking. A good compacted state keeps enough structure for the model to continue operating safely, while dropping repetition, digressions, and stale details that no longer affect the outcome.

What good compaction preserves

The quality of compaction is measured by what survives the reduction. Important items usually include the user’s intent, definitions that were agreed earlier, decisions already made, constraints such as format or policy, and any dependencies that future steps still rely on. If those elements disappear, the model may continue confidently but in the wrong direction.

Good compaction also preserves relationships between facts, not just isolated facts. For example, a preference, a warning, and the reason behind that warning may need to stay linked together, even if the surrounding conversation is shortened.

When compaction is well designed, the shorter representation behaves like a durable working memory for the task, not a vague recap of the chat.

Where compaction breaks down

Poor compaction usually fails by over-compressing. It can flatten nuance, drop a constraint that later becomes critical, or merge distinct decisions into a single vague statement. It can also preserve surface-level wording while losing the operational meaning behind it.

The most dangerous failure mode is silent drift. The model still appears to have context, but key instructions, exceptions, or prior conclusions are missing or distorted. That can lead to inconsistent answers, broken workflows, or unsafe follow-on actions.

Compaction can also be biased by recency, verbosity, or noisy repetition, which means the most important information is not always the information most likely to survive.

Why compaction matters for long-running AI work

Compaction becomes more important as conversations grow longer, tasks become multi-step, and the model has to coordinate across many turns. It is especially relevant when a workflow depends on earlier constraints that are easy to forget, such as approval boundaries, exact wording requirements, or prior decisions that must not be reopened.

For agentic or tool-using systems, compaction affects more than answer quality. It can shape what the system believes it is allowed to do next, what evidence it thinks it has already seen, and which branches of the task remain valid. In that sense, compaction is part of the control surface for continuity and correctness.

Well-managed compaction reduces context bloat without destroying task integrity. Weak compaction saves space at the cost of reliability.

Risk and Threat Considerations

Compaction is risky when it removes the very details that keep a long-running workflow safe, especially explicit constraints, prior decisions, and exception handling. In adversarial or noisy settings, that creates a path for silent task drift, incorrect actions, or loss of guardrails.

Failure mechanism: The model or orchestration layer compresses the conversation too aggressively, then later relies on an incomplete state that no longer reflects the true task history or operational boundaries.

Impact: The system may repeat already-settled decisions, omit critical constraints, follow stale instructions, or take an action that would have been blocked if the full context were still visible.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 addresses the attack and risk surface, while NIST CSF 2.0 sets the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST CSF 2.0GV.RR-01 — Roles, Responsibilities, and AuthoritiesCompaction must retain ownership and decision authority across a long task
PR.AA-05 — Identity and Access ManagementCompacted context can carry access boundaries and action constraints that shape later execution
RC.RP-01 — Recovery Plan ExecutionCompaction supports continuity after interruption by preserving the task plan and recovery-relevant state
Recommendation — Preserve role and authority decisions in the compacted state so later turns do not blur accountability. Keep access limits and approval constraints intact when condensing state for later use. Retain the steps and constraints needed to resume the workflow correctly after context is shortened.
OWASP Agentic AI Top 10ASI06 — Memory & Context PoisoningCompaction failures can erase or distort the context an agent later depends on
Recommendation — Detect and resist context corruption by preserving the task facts that materially affect later agent actions.

Practitioner Guidance

Why practitioners should care: Treat compaction as a safety function, not just a storage optimisation. The practical test is whether the compressed state still supports the next correct decision, especially when the workflow contains approvals, exceptions, or stateful constraints.

What to watch for: Watch for summaries that preserve topical coverage but lose exact commitments, open questions, or prohibitions. That is usually the point where compaction has become too lossy for dependable execution.

Practitioner takeaway: The right compaction strategy is the one that keeps task continuity intact after the conversation is shortened, not the one that produces the smallest representation.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org