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

# conversation.context.get_compacted

> Retrieve an existing compacted summary for a conversation without triggering a new compaction.

```python theme={null}
await sdk.conversation.context.get_compacted(
    conversation_id: str,
    version: Optional[int] = None,
    format: str = "structured",
) -> Optional[CompactionResponse]
```

Fetches the most recent compacted summary for a conversation. Local SDK cache is checked first (5 minute TTL); on miss the SDK fetches from Synap and caches the result. Returns `None` if no compacted summary exists yet. Call [`compact`](/sdk-reference/conversation-context/compact) first in that case.

When a specific `version` is requested the local cache is bypassed and the value is fetched fresh from Synap.

### Parameters

<ParamField path="conversation_id" type="str" required={true}>
  The conversation whose compacted summary you want to read. Must be a valid UUID [registered via `record_message`](/concepts/context-end-to-end#short-term-context).
</ParamField>

<ParamField path="version" type="int" required={false}>
  Specific compaction version. Defaults to the latest. When supplied, the SDK always fetches from the cloud and skips the local cache.
</ParamField>

<ParamField path="format" type="str" required={false} default="structured">
  Output format:

  * `"structured"`: structured fields (`facts`, `decisions`, `preferences`, `current_state`)
  * `"narrative"`: prose summary
  * `"injection"`: preformatted for direct prompt injection
</ParamField>

### Returns

A `CompactionResponse` if a compacted summary exists, otherwise `None`.

<ResponseField name="compacted_context" type="str">The formatted compacted context.</ResponseField>
<ResponseField name="original_token_count" type="int">Token count of the original conversation.</ResponseField>
<ResponseField name="compacted_token_count" type="int">Token count after compaction.</ResponseField>
<ResponseField name="compression_ratio" type="float">Compaction ratio (compacted / original).</ResponseField>
<ResponseField name="level_applied" type="CompactionLevel">Strategy actually applied (e.g., `adaptive`, `balanced`).</ResponseField>
<ResponseField name="compaction_id" type="str | None">Identifier of the compaction run that produced this summary.</ResponseField>
<ResponseField name="strategy_used" type="str | None">Strategy used for this compaction.</ResponseField>
<ResponseField name="validation_score" type="float | None">Quality validation score, when available.</ResponseField>
<ResponseField name="validation_passed" type="bool | None">Whether the validation check passed.</ResponseField>
<ResponseField name="facts" type="List[str]">Extracted facts (structured format).</ResponseField>
<ResponseField name="decisions" type="List[str]">Extracted decisions (structured format).</ResponseField>
<ResponseField name="preferences" type="List[str]">Extracted preferences (structured format).</ResponseField>
<ResponseField name="current_state" type="Dict[str, Any] | None">Snapshot of current conversation state (structured format).</ResponseField>
<ResponseField name="quality_warning" type="str | None">Optional warning when validation flagged a concern.</ResponseField>
<ResponseField name="metadata" type="ResponseMetadata">Correlation id, source (`cache` or `cloud`), TTL, and retrieval timestamp.</ResponseField>

### Example

```python theme={null}
import uuid
from maximem_synap import MaximemSynapSDK

sdk = MaximemSynapSDK(api_key="synap_your_key_here")
await sdk.initialize()

# conversation_id must be a valid UUID; reuse the conversation's id
conversation_id = str(uuid.uuid4())

compacted = await sdk.conversation.context.get_compacted(
    conversation_id=conversation_id,
    format="structured",
)

if compacted is None:
    print("No compaction yet. Trigger one with sdk.conversation.context.compact()")
else:
    print(f"Compressed {compacted.original_token_count} -> {compacted.compacted_token_count} tokens")
    for fact in compacted.facts:
        print("-", fact)
```

### Raises

* `AuthenticationError`: when the API key is missing or invalid.
* `NetworkError`: when the SDK cannot reach Synap.

### See also

* [conversation.context.compact](/sdk-reference/conversation-context/compact)
* [conversation.context.get\_compaction\_status](/sdk-reference/conversation-context/get-compaction-status)
* [conversation.context.get\_context\_for\_prompt](/sdk-reference/conversation-context/get-context-for-prompt)
