> ## Documentation Index
> Fetch the complete documentation index at: https://kapso-1adbad2d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent class

> Create and manage conversational agents

## Basic usage

```python theme={null}
from kapso.builder import Agent
from kapso.builder.agent.constants import START_NODE, END_NODE

agent = Agent(
    name="support_bot",
    system_prompt="You are a helpful support assistant"
)

agent.add_node(START_NODE)
agent.add_node(END_NODE)
agent.add_edge(START_NODE, END_NODE)
agent.validate()
```

## Constructor

```python theme={null}
Agent(
    name: str,
    system_prompt: str = None,
    message_debounce_seconds: int = None
)
```

* **name**: Agent identifier (alphanumeric + underscores)
* **system\_prompt**: Instructions for the LLM
* **message\_debounce\_seconds**: Wait time before processing rapid messages

## Methods

### add\_node()

```python theme={null}
agent.add_node(node)
```

Add a node to the graph. Accepts Node objects or START\_NODE/END\_NODE constants.

### add\_edge()

```python theme={null}
agent.add_edge(source, target, condition=None)
```

Connect two nodes with optional condition.

```python theme={null}
agent.add_edge(START_NODE, "greeting")
agent.add_edge("greeting", "help", condition="user needs help")
```

### validate()

```python theme={null}
agent.validate()
```

Check graph structure. Required before deployment.

## Special nodes

Every agent needs START\_NODE and END\_NODE:

```python theme={null}
from kapso.builder.agent.constants import START_NODE, END_NODE

agent.add_node(START_NODE)  # Entry point
agent.add_node(END_NODE)    # Exit point
```
