# Codatum Agent (Beta)

{% hint style="warning" %}
This feature is currently in beta. Specifications are subject to change without notice.
{% endhint %}

AI Agent is a feature that autonomously performs data analysis and creates or edits Notebooks based on natural language instructions. It can reference catalog and Notebook contents to carry out analysis aligned with your intent.

{% hint style="info" %}
Information included in requests to Codatum Agent is not used for training purposes. However, information that may include Notebook contents and parts of your data sources will be sent to the selected LLM platform. Please review your organization's internal AI usage policy before use.
{% endhint %}

## Key Features

* Natural language instruction execution:
  * Simply enter instructions in the chat, and AI Agent will autonomously perform the necessary operations.
* Content reference:
  * References catalog and Notebook contents to execute query creation and more.
* Table exploration:
  * Automatically explores tables suitable for analysis based on catalog information and table column details.
* Notebook creation and editing:
  * In addition to returning analysis results in the chat, AI Agent can also create new Notebooks or edit existing ones.

## How to Use

For setup instructions and basic usage, please refer to the [User Guide](https://app.codatum.com/public/workspace/6683260fe9a1b289052c4dec/link/69e576ae15aa7830d5b15ff4/notebook/69e575d415aa7830d5b1539b/69dc8c944c2ef1474da7bf1f/?thm=LIGHT\&ts=1776645806811).\
The Agent supports two display modes, each with two available operation modes: ASK mode and Agent mode.

* Display mode
  * **Side Panel Mode**: Launch from the Agent icon in the UI. When viewing a Notebook, it appears as a side panel on the right.
    * Since it uses the currently open Notebook as context, Side Panel Mode is recommended when running Agent while referencing a specific Notebook.
  * **Full-page Mode**: Launch from the side panel in the UI.
    * For data exploration or Notebook creation without referencing a specific Notebook, Full-page Mode makes it easier to view chat content.
* Operation mode
  * **ASK mode**: Performs data analysis including query execution, but does not create or edit Notebooks. Use this when you want to ask questions about your data.
    * When running Agent in Side Panel Mode, ASK mode is recommended if you do not want to edit the Notebook.
  * **Agent mode**: Executes all operations including Notebook creation, editing, and chart additions. Use this when you want to create Notebooks or add charts.

### Permission Scope

Operations by Codatum Agent are executed within the permission scope of the user running the Agent.

* Editor
  * Can perform a wide range of operations including SQL execution and Notebook editing
* Viewer
  * Can only view Notebook contents and previously executed data

Notebooks the Agent can explore and connections available to the Agent are also limited to what the executing user has access to.

{% hint style="info" %}
There is currently no feature to set custom permission scopes for the Agent. If there is data you do not want the Agent to access, you should take operational precautions such as manually approving each SQL execution. You can limit the exploration scope to some extent by specifying it in the agent context file.
{% endhint %}

### Agent Context

You can click the "book" icon in the upper left of the text box to view the context being passed to the Agent.

### Specifying Context

Use `@` to specify the context for AI Agent to reference.

| View                                       | Available Context                            |
| ------------------------------------------ | -------------------------------------------- |
| While viewing a Notebook (Side Panel Mode) | Tables, Notebooks, Saved Queries, SQL Blocks |
| Full-page Mode and other views             | Tables, Notebooks, Saved Queries             |

## Agent Screen

### Icons

The following actions are available from the icons in the upper right of the Agent chat panel:

* New chat
  * Leave the current chat and start a new one.
    * As context grows, token consumption efficiency decreases. It is recommended to start a new chat when switching to a different analysis.
* Chat history
  * View the history of past chats.
* Session info
  * Check usage details such as start time and total tokens used.
  * You can also navigate from Side Panel Mode to Full-page Mode here.
* Close
  * Close the chat panel.

The following action is available from the bottom of the chat input area:

* Send feedback
  * You can send feedback to the Codatum team.
    * If you check "Include conversation log" or "Include page context," please make sure your conversation does not contain any sensitive information.

### Agent Settings

The following settings are available from the Agent settings at the bottom of the text box:

* Switch between ASK mode / Agent mode
* Switch preferred connection:
  * You can select the connection to use preferentially.
  * When set to the default Auto, the agent selects the most appropriate connection.
* User settings
  * Line break with Enter
  * Auto-approve tool execution:
    * You can configure whether SQL queries are automatically executed per connection.
    * For BigQuery, you can also set an upper limit on the query read size that can be auto-executed, based on dry run results.
  * Auto-load agent context:
    * You can configure whether agent context files are automatically loaded.
  * Switch AI profile:
    * You can select which of your configured AI profiles to use.
    * Each AI profile can have its own model and context notebook settings, allowing you to switch between models and contexts depending on your use case.
    * See also: [AI Profile](/ai-assist/ai-profile.md)
  * Language

## Agent Context File

You can create an agent context folder at the following levels:

* Workspace
* Team space
* Private folder

You can also create an agent context page for individual Notebooks by adding a page named `.agent`.

By adding SQL blocks to a context file, you can pass information such as how specific metrics are calculated to the Agent as context.

## Checking Usage

You can check your token usage by navigating to **Workspace Settings** > **Subscription** > **Usage** from the navigation on the left side of the screen.

## Unsupported Pages

AI Agent is currently not available on the following pages:

* Notebook Home
* Query
* Catalog
* Workflow
* Report

## Data Privacy

Requests to Codatum Agent are not used for training purposes. When executing requests to the Agent, parts of your Notebook contents and data may be sent to the LLM endpoint as context.

{% hint style="info" %}
For inquiries about the AI Agent feature, please contact us via chat or `support@codatum.com`.
{% endhint %}


---

# Agent Instructions: 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.codatum.com/ai-assist/ai-agent.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.
