> For the complete documentation index, see [llms.txt](https://docs.andmilo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.andmilo.com/the-and-milo-agent-architecture/memory-and-system-state.md).

# Memory & System State

\&milo’s architecture is built upon a structured memory system that allows agents to retain context, recall past interactions, and track system state. A well-defined memory and state management system is crucial for an Agentic (semi)Autonomous System, ensuring that agents can make informed decisions, personalize responses, and optimize execution strategies.

## At its core, memory is divided into three key layers:

### 1. Short-Term Memory (Contextual Awareness)

Short-term memory is responsible for maintaining immediate context, allowing agents to track ongoing conversations and tasks.

• **Session-Based:** Agents retain user inputs and responses within a single interaction session.

• **Token-Aware Processing:** Optimized for efficient use of context windows, ensuring that relevant information is preserved while unnecessary data is discarded.

• **Ephemeral Storage:** Data in short-term memory exists only for the duration of the session, preventing unnecessary retention of transient information.

### 2. Long-Term Memory (User Preferences & Historical Context)

Long-term memory allows agents to store and recall user-specific preferences, historical interactions, and learned behaviors over time.

**• Cross-Session Continuity:** Ensures that users do not need to reconfigure preferences or reintroduce past conversations each time they interact with the system.

**• Personalization:** Agents adjust behaviors based on previously stored user-specific data (e.g., preferred execution parameters, trading strategies, or risk appetite).

**• Retrieval-Augmented Learning:** Structured indexing mechanisms allow agents to retrieve relevant past data dynamically, optimizing decision-making without unnecessary memory bloat.

### 3. System State Memory (Live System Awareness & Execution Data)

The System State Memory is the most critical layer, providing agents with real-time awareness of ongoing operations, resources, and execution parameters.

**• Real-Time System Knowledge:** Tracks active positions, asset balances, executed trades, and pending transactions.

**• Stateful Execution:** Ensures that agents always have a consistent view of the system, preventing redundant actions or conflicts in multi-agent workflows.

####

#### **System State & Agent Execution**

The System State Memory serves as the foundational execution layer for all agents. Every agent consults real-time system memory before making critical decisions.

For example, before executing a transaction, an agent would:

1\. Check live wallet balances to confirm that sufficient funds are available.

2\. Verify open positions to avoid duplicate trades or conflicting strategies.

3\. Synchronize with other agents to ensure that no concurrent action is overriding its execution.

**Deterministic RAG for System State**

Unlike generic retrieval-augmented generation (RAG) architectures that fetch arbitrary knowledge, \&milo employs a highly controlled, deterministic RAG model. This ensures that:

✔ Only relevant system data is retrieved based on the agent’s role and execution state.

✔ Memory queries are structured, preventing hallucinations or ambiguous knowledge retrieval.

✔ Execution-critical data is prioritized, ensuring the system remains aligned with real-world conditions.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.andmilo.com/the-and-milo-agent-architecture/memory-and-system-state.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
