> ## 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.fetch

> Fetch conversation-scoped context (facts, preferences, episodes) for a specific conversation.

```python theme={null}
await sdk.conversation.context.fetch(
    conversation_id: str,
    search_query: Optional[List[str]] = None,
    max_results: int = 10,
    types: Optional[List[str]] = None,
    mode: str = "fast",
    user_id: Optional[str] = None,
    customer_id: Optional[str] = None,
) -> ContextResponse
```

Retrieves the context Synap has built up for a single conversation: facts surfaced from earlier turns, user preferences, episodic memories, emotional cues, and temporal events. Use this to assemble grounding material before generating the next assistant turn.

Passing `user_id` (and `customer_id`) is strongly recommended: it scopes the in-process anticipation cache to that user so bundles prefetched for one user can never be served on another user's lookup. These will become required in a future release.

### Parameters

<ParamField path="conversation_id" type="str" required={true}>
  The conversation to fetch context for. Must be a valid UUID (e.g. `str(uuid.uuid4())`), the same id you used when [recording the conversation's messages](/concepts/context-end-to-end#short-term-context).
</ParamField>

<ParamField path="search_query" type="List[str]" required={false}>
  Optional list of query strings to bias retrieval. When omitted, the most relevant recent context is returned.
</ParamField>

<ParamField path="max_results" type="int" required={false} default="10">
  Maximum number of items to return per context type.
</ParamField>

<ParamField path="types" type="List[str]" required={false}>
  Context types to include. Defaults to all available types (facts, preferences, episodes, emotions, temporal events).
</ParamField>

<ParamField path="mode" type="str" required={false} default="fast">
  Retrieval mode: the retrieval axis (`fast` vs `accurate`) of [Retrieval Modes](/concepts/retrieval-modes):

  * `"fast"`: direct query, lower latency. Best for in-the-loop prompt assembly.
  * `"accurate"`: LLM-enhanced queries, higher quality at higher latency. Best when you can afford the extra latency.

  For real per-mode latency on your instance, see **Dashboard → Usage**.
</ParamField>

<ParamField path="user_id" type="str" required={false}>
  External user id. Strongly recommended: scopes anticipation cache lookups to the right user and avoids deriving scope from a not-yet-written conversation row.
</ParamField>

<ParamField path="customer_id" type="str" required={false}>
  External customer id, forwarded alongside `user_id` for the same scoping reason. Required on B2B; auto-resolved on B2C. See [B2C vs B2B](/concepts/memory-scopes#b2c-vs-b2b-which-scopes-apply-to-you).
</ParamField>

### Returns

A `ContextResponse` containing the retrieved context.

<ResponseField name="facts" type="List[Fact]">Facts learned about the user during this conversation.</ResponseField>
<ResponseField name="preferences" type="List[Preference]">Stated or inferred preferences relevant to this conversation.</ResponseField>
<ResponseField name="episodes" type="List[Episode]">Episodic memories tied to this conversation.</ResponseField>
<ResponseField name="emotions" type="List[Emotion]">Detected emotional signals.</ResponseField>
<ResponseField name="temporal_events" type="List[TemporalEvent]">Time-anchored events relevant to the conversation.</ResponseField>
<ResponseField name="conversation_context" type="Dict[str, Any]">Compacted/summary context for this conversation, when available.</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()

# reuse the same conversation_id you recorded messages under
conversation_id = str(uuid.uuid4())

ctx = await sdk.conversation.context.fetch(
    conversation_id=conversation_id,
    search_query=["dinner plans", "dietary restrictions"],
    max_results=5,
    mode="fast",
    user_id="user_alice",
    customer_id="customer_acme",
)

for fact in ctx.facts:
    print(fact.content)
```

### Raises

* `InvalidInputError`: when `mode` is not `"fast"` or `"accurate"`.
* `AuthenticationError`: when the API key is missing or invalid.
* `NetworkError`: when the SDK cannot reach Synap.

### See also

* [conversation.record\_message](/sdk-reference/conversation/record-message)
* [conversation.context.compact](/sdk-reference/conversation-context/compact)
* [conversation.context.get\_context\_for\_prompt](/sdk-reference/conversation-context/get-context-for-prompt)
