# AI agent

> Answers with AI, using the steps you give it as tools, and remembers the conversation. Give it fields to have it pull details out of a document or sort it. Uses credits on every message.

Source: https://docs.go-lumen.ai/reference/steps/chat-agent

## At a glance

| Property | Value |
| --- | --- |
| **Step name** | `chat-agent` |
| **Resource** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Palette group, category** | ai, ai |
| **Credits** | **3** credits each time it succeeds |
| **Side effects** | no |
| **Installation must provide** | nothing |

## Inputs

| Property | Value |
| --- | --- |
| **Needs** | nothing |
| **Produces** | `fields` |
| **Works on** | item: one document at a time |

Needs and Produces are data types (file, text, fields, email). The editor offers a step only where what it needs is already on the path. See [Documents and data](https://docs.go-lumen.ai/concepts/how-flows-run.md#documents-and-data).

## Outputs

More outputs are declared in the setting \`fields\`.

## Settings

Set under `config:` on the flow node. Text settings may contain `{nodeId.field}` placeholders.

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `instructions` | string |  | Instructions replace the step's: what the agent is for and how it answers. Placeholders (`{message}`, `{<nodeId>.<field>}`) are filled from the document. (minLength 1; maxLength 8000) |
| `tools` | list of string |  | Tools replace the step's: the ClusterSteps it may call, by name. (maxItems 16) |
| `memory` | object |  | Memory replaces the step's: how many earlier turns of the session it reads. |
| `memory.window` (required) | integer |  | Window is how many earlier turns (a message and its reply) it reads. (minimum 1; maximum 50) |
| `longTermMemory` | object |  | LongTermMemory sets how the notes the agent keeps are kept. Whether the agent has a long-term memory at all is whether the memory tools (remember, recall, forget) are among its Tools. |
| `longTermMemory.retentionDays` | integer |  | RetentionDays makes the notes the agent saves from now on expire after that many days; unset keeps them until they are forgotten. (minimum 1; maximum 3650) |
| `longTermMemory.autoRecall` | integer |  | AutoRecall is how many notes the harness recalls at the start of each run and puts in the prompt, so the agent need not remember to look: 3 when unset, 0 turns it off, at most 10. They use tokens on every run. (minimum 0; maximum 10) |
| `modelRef` | object |  | ModelRef is the model this node runs on, before the step's and the tenant's: a ClusterModelClass, or the tenant's own ModelClass in its namespace. |
| `modelRef.kind` | string |  | Kind is ClusterModelClass (the default) or ModelClass. (one of ClusterModelClass, ModelClass) |
| `modelRef.name` (required) | string |  | (minLength 1) |
| `files` | object |  | Files is how the agent reads its document's files: whole when its model reads them, as text otherwise, within limits. |
| `files.mode` | string | `"attach"` | Mode is attach (the model reads each file whole when it can, its text otherwise), text (only the text read out of each file) or none (no file at all). Unset is attach. ifNoText attaches them only when the document has no text, and sends none otherwise. (one of attach, text, none, ifNoText) |
| `files.maxFiles` | integer | `10` | MaxFiles is the most files one document may bring; the rest are skipped. Unset is 10. (minimum 1; maximum 100) |
| `files.maxPages` | integer | `100` | MaxPages is the most PDF pages across all files together; a PDF that crosses it is read up to the pages left. Unset is 100. (minimum 1; maximum 1000) |
| `files.maxBytes` | integer | `20971520` | MaxBytes is the most bytes, all files together. Unset is 20 MB. (minimum 1; maximum 104857600) |
| `guardrails` | object |  | Guardrails are the rules the agent follows, the limits on its tools and what is masked in its output. |
| `guardrails.rules` | list of string |  | Rules are told to the agent as rules it must follow. (maxItems 20) |
| `guardrails.tools` | map of object |  | Tools limits what the agent's tools may do, by the tool's step name. |
| `guardrails.output` | object |  | Output masks what the agent's reply and output fields must not carry. |
| `guardrails.output.redact` | list of string |  | Redact lists what is masked: creditCard, israeliID, email, phone. (maxItems 4) |
| `guardrails.tables` | object |  | Tables limits which tables the agent's table tools may touch: unset is no limit. |
| `guardrails.tables.write` | list of string |  | (maxItems 50) |
| `guardrails.tables.read` | list of string |  | (maxItems 50) |
| `mcp` | list of object |  | MCP are tools of the workspace's MCP connections the agent may call, by connection and tool name. Only tools an admin allowed on the connection run; the model calls one as "<connector>/<tool>". (maxItems 8) |
| `mcp[].connector` (required) | string |  | (minLength 1; maxLength 253) |
| `mcp[].tools` (required) | list of string |  | (minItems 1; maxItems 16) |
| `limits` | object |  | Limits are this agent's safety caps, enforced while it works: a cap reached stops it and fails the step. A saved agent Step carries them for every flow that uses it. |
| `limits.maxTurns` | integer |  | MaxTurns replaces the step's limit of model turns. (minimum 1; maximum 100) |
| `limits.maxTokens` | integer |  | MaxTokens caps the tokens (input and output) the agent uses. (minimum 1; maximum 100000000) |
| `limits.maxMinutes` | integer |  | MaxMinutes caps how long the agent works. (minimum 1; maximum 1440) |
| `browser` | object |  | Browser gives the agent a browser signed in to a website-login connection: the browser.\* tools, acting on that site only. It needs the installation's browser capability. |
| `browser.connectorRef` (required) | string |  | ConnectorRef is the website-login Connector in the workspace. (minLength 1) |
| `fields` | list of object |  | Fields are the details the agent answers in, each one an output of the node under its name, typed by its type, with its hint told to the model. A simple extraction is one agent node with fields: AI in a flow runs only through the agent step. (maxItems 50) |
| `fields[].name` (required) | string |  | (minLength 1) |
| `fields[].hint` | string |  | Hint is more labels to look for, comma separated: "Amount due, סכום". |
| `fields[].type` | string |  | Type is what the detail is: string, number, date (YYYY-MM-DD) or money ({amount, currency}). Unset is string, except that a known detail (date, total) keeps its own type. (one of string, number, date, money) |
| `knowledge` | object |  | Knowledge is the agent's Lighthouse: which collections' documents it may read, and whether it is given the workspace's approved rules (by default it is; rules false keeps them out). |
| `knowledge.collections` | list of string |  | Collections are KnowledgeCollections of the workspace, by name. (maxItems 8) |
| `knowledge.mode` | string |  | Mode is how they are given: inject puts their text in the prompt, auto injects a collection under the inject budget. retrieve (the search tool) is not built yet. (one of auto, inject) |
| `knowledge.rules` | boolean |  | Rules false keeps the workspace's approved rules out of this agent's prompt, for an agent that talks to customers: the rules come from the workspace's own documents, which may be private. Unset or true gives them. |

The full JSON Schema of these settings: [chat-agent.schema.json](https://docs.go-lumen.ai/schemas/steps/chat-agent.schema.json).

## Example

Draft a reply to a quote request

```yaml title="config"
instructions: You help a small print shop answer customers. Answer briefly and politely,
 in the language the person wrote in.
```

## Use it in a flow

A node that runs `chat-agent` goes under `spec.nodes` of a [Flow](https://docs.go-lumen.ai/concepts/how-flows-run.md#the-flow-as-yaml). Give it any id, and list the next node ids in next.

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: chat-agent-example
  namespace: tenant-acme
spec:
  displayName: "AI agent"
  triggers:
    - id: start
      ref: {name: manual-run}
      next: [chat-agent]
  nodes:
    - id: chat-agent
      stepRef: {name: chat-agent}
      config:
        instructions: You help a small print shop answer customers. Answer briefly and politely,
          in the language the person wrote in.
```
