> For the complete documentation index, see [llms.txt](https://docs.cyne.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cyne.ai/core-concept/agent.md).

# Agent

Agents are the foundational elements of the CYNE AI framework, enabling seamless, intelligent, and autonomous interactions within the Solana ecosystem.

**Example: State Methods**

* **Compose Initial State:**

```typescript
const state = await runtime.composeState(message, {
    additionalContext: "custom blockchain context",
});
```

* **Update State:**

```typescript
const updatedState = await runtime.updateRecentMessageState(state);
```

**Best Practices:**

* Use `composeState` to initialize new states.
* Update states dynamically during interactions with `updateRecentMessageState`.
* Cache frequently accessed data to enhance performance.

***

#### Memory Systems in CYNE AI

Memory systems provide agents with contextual understanding and continuity.

**Types of Memory:**

1. **Message History:** Tracks past interactions for conversational continuity.
2. **Factual Memory:** Stores specific details like wallet activity or token preferences.
3. **Knowledge Base:** Retains general knowledge about Solana, DeFi, and NFTs.
4. **Relationship Tracking:** Builds rapport by storing user-agent interaction history.

**Memory Managers:**

CYNE AI provides specialized memory managers:

* **`messageManager`:** Tracks conversation history.
* **`descriptionManager`:** Stores user profiles and descriptions.
* **`loreManager`:** Retains agent knowledge and backstory.

**Example: Memory Management**

```typescript
const memoryManager = runtime.getMemoryManager("messages");

// Store memory
await memoryManager.createMemory({
    id: messageId,
    content: { text: "Analyzed a 1M SOL whale transaction" },
    userId: "user123",
    roomId: "room123",
});
```

***

#### Evaluation System

The **evaluate** method processes input, evaluates responses, and determines actionable outcomes.

**Example: Evaluation**

```typescript
const evaluationResults = await runtime.evaluate(message, state, didRespond);
```

***

#### Best Practices for Agent Implementation

1. **Use Randomized Memory:** For more dynamic agent responses.
2. **Optimize Memory Usage:** Clean old data periodically to avoid performance bottlenecks.
3. **Handle Errors Gracefully:** Log errors to maintain stability.
4. **Follow Immutability Principles:** For state management to ensure reliability.

***

#### Further Reading and Resources

* **Actions Documentation:** Learn how to configure and extend agent actions.
* **Evaluators Documentation:** Dive into evaluation and goal-setting for agents.
* **Providers Documentation:** Connect agents to external platforms and tools.
* **Full API Reference:** Explore the full technical details of CYNE AI.

Start building intelligent agents with **CYNE AI** today!


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.cyne.ai/core-concept/agent.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
