# History

**Category:** Agent configuration\
**Version:** 1.0\
**Last updated:** March 26, 2026\
**Author:** Any2Info

***

### Description

The **History & File Retention** settings control how conversations and associated file references are stored and cleaned up for an agent.

Within Any2Info, it is important to distinguish between two storage layers:

* **Any2Info conversation storage** (internal persistence)
* **AI provider storage** (temporary or persistent, depending on configuration and mode)

A *conversation* represents the stored input and output of an agent execution. This applies to both chat-enabled and non-chat agents.

***

### Chat vs Non-Chat Behavior

| Mode          | Behavior                                                                                                                                                                                                                                                |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Chat enabled  | AI provider calls are stateful. Previous messages are included in subsequent requests. Files remain available in provider storage for the duration of the conversation. Conversations are always created and stored, regardless of the history setting. |
| Chat disabled | AI provider calls are stateless. Messages are not chained in requests. Files are cleaned up immediately after each request. Conversations are only stored when history is enabled.                                                                      |

> When chat is enabled and history is disabled, conversations are still stored internally but are **not accessible to the user through normal means**.

***

### Conversation Storage

#### Chat Enabled

* A **conversation instance is always created**
* Messages are chained both:
  * In AI provider calls
  * In stored conversation data
* If history is disabled:
  * Conversation is still stored
  * Conversation is **not accessible to the user**

#### Chat Disabled

* A conversation is created **only when history is enabled**
* Messages are stored and chained in the conversation
* AI provider calls remain stateless (no chaining)

***

### File Handling & Storage

#### Within Any2Info Conversations

| File type                                 | Stored data                  |
| ----------------------------------------- | ---------------------------- |
| Images                                    | Full base64 content          |
| Other files (PDF, Word, Excel, TXT, etc.) | File name and extension only |

> File content (except images) is not stored in Any2Info.

***

#### AI Provider Handling

**Images**

* Sent as base64
* Never stored in provider storage

**Text / Content Files**

* If supported → uploaded to provider storage
* If not supported → converted to text and sent inline

**Example (OpenAI):**

* Only PDF files are stored in provider storage
* Other file types are converted to text

***

### File Lifecycle in AI Provider

#### Non-Chat Enabled Agents

* Files are uploaded to provider storage **during request execution**
* After receiving a response:
  * Files are **immediately removed** from provider storage
* No persistence beyond a single request

> Any2Info still stores the file reference (name + extension)

***

#### Chat Enabled Agents

* Files are uploaded when provided as input
* Files remain in provider storage for the **entire conversation lifecycle**
* Files are reused across subsequent requests within the same conversation

***

### Configuration Options

| Setting             | Required | Description                                                                                                                                    |
| ------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| Max duration (days) | No       | Defines how long a conversation may remain unused before being eligible for cleanup. The timer resets whenever the conversation is used again. |
| Max count           | No       | Defines the maximum number of stored conversations per agent. Oldest conversations are removed when the limit is exceeded.                     |

***

### Conversation Lifecycle

#### Max Count

* Limits the number of stored conversations per agent
* Example:
  * Max count = 10
  * When the 11th conversation is created → conversation 1 is deleted

***

#### Max Duration

* Defines how long a conversation may remain unused
* Based on **last usage timestamp**
* The duration is reset whenever the conversation is used again

Example:

* Max duration = 2 days
* Last used: January 1, 13:18
* User interacts again on January 2 → timer resets
* New expiry: January 4, based on last interaction
* Conversation is removed during the first cleanup cycle after expiry

> The duration only applies to **continuous inactive (stale) periods**

***

#### Cleanup Cycles

* Executed **hourly**
* Both **max duration** and **max count** are evaluated every cycle
* Configuration changes take effect **immediately on next cycle**

***

### Deletion & Cleanup Behavior

When a conversation is cleaned:

#### Any2Info

* Conversation is **marked as deleted**
* Data remains in the database (soft delete)

#### AI Provider

* All associated files are **permanently removed** from provider storage

#### User-triggered Cleanup

A conversation can also be explicitly ended by the user. In this case, cleanup is executed **identically** to the automatic cleanup process.

Ways a user can trigger this:

* Using the **clear messages** action in an agent
* Leaving a **stateless (non-chat) agent conversation**

***

### Usage

Use **History & File Retention** to manage:

* Storage lifecycle of conversations
* Cleanup of AI provider stored files
* Data retention policies

Typical use cases:

* Limiting storage usage
* Managing temporary or sensitive data
* Ensuring cleanup of uploaded files
* Controlling conversation lifecycle

***

### Important Notes

* File retention is fully dependent on the **conversation lifecycle**
* There is no independent file retention mechanism
* **Max count** indirectly affects file retention
* Images are stored differently than other file types (base64 vs metadata)
* AI provider storage behavior depends on:
  * Provider capabilities
  * Chat vs non-chat mode
* Disabling history only affects **user accessibility**, not whether conversations exist (in chat mode)

***

### Tips & Best Practices

* Use **Max duration** for time-based cleanup policies
* Use **Max count** to control storage volume
* Prefer non-chat mode for immediate file cleanup scenarios
* Use chat mode when file reuse across interactions is required
* Be aware of hourly cleanup cycles when designing workflows

***

### Changelog

| Version | Date           | Change                               |
| ------- | -------------- | ------------------------------------ |
| 1.0     | March 26, 2026 | Initial documentation version added. |
