> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/engineering-reference/db/tables/ai_agent_messages.md).

# ai\_agent\_messages

{% hint style="info" %}
Generated from the staging database schema, with descriptions drafted by agents ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). [Source on GitHub](https://github.com/snapfix/docs/blob/main/spec/db/tables/ai_agent_messages.md).
{% endhint %}

## Description

One message of an AI agent chat, by the user or the assistant. No repo reads or writes it; snapfix\_ai\_agent keeps Simon's chat turns in its own table simon\_messages, which the staging schema does not have \[[ASK-179](https://github.com/snapfix/docs/blob/main/ASK.md#ask-179-which-database-does-snapfix-ai-use-in-production-and-are-the-ai_agent_-tables-still-used)].

<details>

<summary><strong>Table Definition</strong></summary>

```sql
CREATE TABLE `ai_agent_messages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` char(36) NOT NULL,
  `uuid_tParent` varchar(64) DEFAULT NULL,
  `uuid_tUser` varchar(64) DEFAULT NULL,
  `sessionId` varchar(128) NOT NULL,
  `role` varchar(16) NOT NULL COMMENT 'user | assistant',
  `content` mediumtext NOT NULL,
  `domain` varchar(64) DEFAULT NULL,
  `fDeleted` tinyint(1) NOT NULL DEFAULT '0',
  `fCreatedTs` int unsigned NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_ai_agent_messages_uuid` (`uuid`),
  KEY `idx_ai_agent_messages_user_parent_id` (`uuid_tUser`,`uuid_tParent`,`id`),
  KEY `idx_ai_agent_messages_user_id` (`uuid_tUser`,`id`),
  KEY `idx_ai_agent_messages_session_id` (`sessionId`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
```

</details>

## Columns

| Name          | Type            | Default | Nullable | Extra Definition | Comment           |
| ------------- | --------------- | ------- | -------- | ---------------- | ----------------- |
| id            | bigint unsigned |         | false    | auto\_increment  |                   |
| uuid          | char(36)        |         | false    |                  |                   |
| uuid\_tParent | varchar(64)     |         | true     |                  |                   |
| uuid\_tUser   | varchar(64)     |         | true     |                  |                   |
| sessionId     | varchar(128)    |         | false    |                  |                   |
| role          | varchar(16)     |         | false    |                  | user \| assistant |
| content       | mediumtext      |         | false    |                  |                   |
| domain        | varchar(64)     |         | true     |                  |                   |
| fDeleted      | tinyint(1)      | 0       | false    |                  |                   |
| fCreatedTs    | int unsigned    |         | false    |                  |                   |

## Viewpoints

| Name                                                                           | Definition                                                                                                                                             |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [ai](https://docs.snapfix.com/engineering-reference/db/tables/viewpoint-17.md) | Snapfix AI and AI suggestions: agent sessions and messages, brand documents, task insight and title-style data, token usage, the AI job log and queue. |

## Constraints

| Name                          | Type        | Definition                                      |
| ----------------------------- | ----------- | ----------------------------------------------- |
| PRIMARY                       | PRIMARY KEY | PRIMARY KEY (id)                                |
| uq\_ai\_agent\_messages\_uuid | UNIQUE      | UNIQUE KEY uq\_ai\_agent\_messages\_uuid (uuid) |

## Indexes

| Name                                       | Definition                                                                                  |
| ------------------------------------------ | ------------------------------------------------------------------------------------------- |
| idx\_ai\_agent\_messages\_session\_id      | KEY idx\_ai\_agent\_messages\_session\_id (sessionId, id) USING BTREE                       |
| idx\_ai\_agent\_messages\_user\_id         | KEY idx\_ai\_agent\_messages\_user\_id (uuid\_tUser, id) USING BTREE                        |
| idx\_ai\_agent\_messages\_user\_parent\_id | KEY idx\_ai\_agent\_messages\_user\_parent\_id (uuid\_tUser, uuid\_tParent, id) USING BTREE |
| PRIMARY                                    | PRIMARY KEY (id) USING BTREE                                                                |
| uq\_ai\_agent\_messages\_uuid              | UNIQUE KEY uq\_ai\_agent\_messages\_uuid (uuid) USING BTREE                                 |

## Relations

```mermaid
erDiagram


"ai_agent_messages" {
  bigint_unsigned id PK
}
```

***

> Generated by [tbls](https://github.com/k1LoW/tbls)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snapfix.com/engineering-reference/db/tables/ai_agent_messages.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
