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

# Load past history

> Backfill historical messages in chronological order with original timestamps

## Example use case

You already have six months of prospect emails and call notes before launching your sales agent, or a year of incident summaries for your team assistant. The agent should know that full timeline before its first live conversation.

## Setup

Create a thread (or one thread per historical conversation) and backfill via JSON [POST`/v2/agents/{agent_id}/threads/{thread_id}/observe`](https://www.sapientpriors.com/docs/api-reference/v2/threads/learn-messages-or-files):

* Sort messages strictly **oldest to newest** and send up to **100 messages per call**.
* Set `timestamp` on every message to its original RFC 3339 UTC time and set `speaker` (plus `speaker_id` when available).
* Attach a unique `Idempotency-Key` per batch.
* Poll [GET`.../observe/{observation_id}`](https://www.sapientpriors.com/docs/api-reference/v2/threads/get-learning-status) until `status` is `committed` before sending the next batch to the same agent.

## Benefit with Priors

* **Accurate timeline recall:** every extracted memory inherits the original `timestamp`, enabling date-aware questions like "what changed since August?".
* **High-throughput batching:** up to 100 messages per `observe` call minimizes HTTP overhead while preserving exact intra-batch order.

## What goes wrong

> [!WARNING]
>
> Omitting `timestamp` stamps every historical message with the current time, flattening months of history into one instant and breaking timeline reasoning. Sending concurrent `observe` calls to the same agent triggers `429 rate_limit_exceeded` (`Retry-After: 1`) or scrambles order across batches. Sending batches newest-first makes superseded facts appear newer than later corrections.

## Recommendation

Sort oldest-first, batch up to 100 messages per `observe` request with exact `timestamp` and `speaker` fields, include an `Idempotency-Key`, and wait for `committed` between calls on the same agent.

## Calls used

* Guides: [Learning](https://www.sapientpriors.com/docs/concepts/learning.md), [Limits](https://www.sapientpriors.com/docs/limits.md), [Integration notes](https://www.sapientpriors.com/docs/integration.md)
* API reference: [Create thread](https://www.sapientpriors.com/docs/api-reference/v2/threads/create-thread.md), [Learn messages or a file](https://www.sapientpriors.com/docs/api-reference/v2/threads/learn-messages-or-files.md), [Get learning status](https://www.sapientpriors.com/docs/api-reference/v2/threads/get-learning-status.md)


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