> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Compression

> Public compression signatures and configuration in @agentium/core 4.0.0.

Import these **2 exports** from `@agentium/core`. Read the [compression guide](/features/compression) for setup and behavior, or return to the [package reference](/api-reference/core).

A `?` marks an optional field. These are declarations for lookup; run the examples in the linked guide. Follow related-type links for Agentium types and source links for imported dependency types.

## CompressionManager

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/compression/compression-manager.ts)

```typescript theme={null}
export declare class CompressionManager {
    constructor(config: CompressionManagerConfig);
    /**
     * Set the fallback model (used when config.model is not provided).
     * Called by the Agent with its primary model so compression can work without explicit model config.
     */
    setFallbackModel(model: ModelProvider): void;
    /** Reset per-run state. Call at the start of each agent run. */
    reset(): void;
    /**
     * Process messages before an LLM call. Compresses tool results when thresholds are exceeded.
     * Designed to be called from the LoopHooks.beforeLLMCall hook.
     */
    process(messages: ChatMessage[], modelId?: string): Promise<ChatMessage[] | undefined>;
    /** Track tool result additions to count toward compressAfter threshold. */
    trackToolResult(): void;
}
```

Related: [`ChatMessage`](/api-reference/core/models#chatmessage), [`CompressionManagerConfig`](/api-reference/core/compression#compressionmanagerconfig), [`ModelProvider`](/api-reference/core/models#modelprovider).

## CompressionManagerConfig

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/compression/compression-manager.ts)

```typescript theme={null}
export interface CompressionManagerConfig {
    /** Model used for compression summaries. Falls back to main model if not set. */
    model?: ModelProvider;
    /** Compress after N uncompressed tool results. Default: 3. */
    compressAfter?: number;
    /** Compress when total context exceeds this token count. Takes priority over compressAfter. */
    tokenLimit?: number;
    /** Custom compression prompt. */
    instructions?: string;
}
```

Related: [`ModelProvider`](/api-reference/core/models#modelprovider).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.