> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superagentx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent

An `Agent` from `superagentx.agent` is a system or program that is initialized with specific goals and roles, enabling it to interact with a
large language model (LLM) and use a predefined prompt template. It is designed to perform agent by following a
set of instructions and can be customized with various parameters to adapt its behavior to different agent or
workflows. Essentially, the `agent` acts as a flexible tool that can be fine-tuned to carry out specific functions
based on the needs of the user.

### Agent Parameters

| Attribute                      | Parameters        | Description                                                                                                                                                                                  |
| :----------------------------- | :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Goal**                       | `goal`            | The primary objective or goal that the engine is designed to achieve.                                                                                                                        |
| **Role**                       | `role`            | The role or function that the engine will assume in its operations.                                                                                                                          |
| **LLM Client**                 | `llm`             | Interface for communicating with the large language model (LLM).                                                                                                                             |
| **Prompt Template**            | `prompt_template` | Defines the structure and format of prompts sent to the LLM using PromptTemplate.                                                                                                            |
| **Engines**                    | `engines`         | A list of engines (or lists of engines) that the engine can utilize. This allows for flexibility in processing and task execution based on different capabilities or configurations.         |
| **Agent ID** *(optional)*      | `agent_id`        | A unique identifier for the engine. If not provided, a new UUID will be generated by default. Useful for tracking or referencing the engine in multi-engine environments.                    |
| **Name** *(optional)*          | `name`            | An optional name for the engine, providing a more friendly reference for display or logging purposes.                                                                                        |
| **Description** *(optional)*   | `description`     | An optional description that provides additional context or details about the engine's purpose and capabilities.                                                                             |
| **Output Format** *(optional)* | `output_format`   | Specifies the desired format for the engine's output. This can dictate how results are structured and presented.                                                                             |
| **Max Retry** *(optional)*     | `max_retry`       | The maximum number of retry attempts for operations that may fail.Default is set to 5. This is particularly useful in scenarios where transient errors may occur, ensuring robust execution. |

```python theme={null}
from superagentx.agent import Agent

ecom_agent = Agent(
        name='Ecom Agent',
        goal="Get me the best search results",
        role="You are the best product searcher",
        llm=llm_client,
        prompt_template=prompt_template,
        engines=[[amazon_engine, walmart_engine]],
        agent_id="ecom-id-1",
        description="""E-commerce enables buying and selling products online,
        providing customers with the convenience of shopping anytime, anywhere.
        It connects buyers and sellers through digital platforms, offering
        secure transactions and delivery.
        """,
        output_format="Generate as JSON format",
        max_retry=5
    )
```

## Agent Configuration

### Sequence

In sequence execution, `engine(s)` are performed one after another, with each `engine(s)` waiting for the
previous one to finish before starting. This approach is simple but can be slow if `engine(s)` are independent.

```python theme={null}
from superagentx.agent import agent

agent = Agent(
    ...
    engines=[engine_1, engine_2, engine_3 ... engine_n],
    ...
)

# Engines execution will be in following order
# [engine_1, engine_2, engine_3 ... engine_n]
```

#### Alternate way of configure

```python theme={null}
from superagentx.agent import agent

agent = Agent(
    ...,
    ...
)

await agent.add(engine_1, engine_2, execute_type='SEQUENCE')
.
.
.
await agent.add(engine_3, engine_4, execute_type='SEQUENCE')
.
.

# Engines execution will be in following order
# [engine_1, engine_2, engine_3, engine_4]
```

### Parallel

In parallel execution, `engine(s)` run at the same time, speeding up the process by utilizing multiple threads or processes.

```python theme={null}
from superagentx.agent import agent

agent = Agent(
    ...
    engines=[[engine_1, engine_2, engine_3 ... engine_n]],
    ...
)

# Engines execution will be in following order
# [[engine_1, engine_2, engine_3 ... engine_n]]
```

#### Alternate way of configure

```python theme={null}
from superagentx.agent import agent

agent = Agent(
    ...,
    ...
)

await agent.add(engine_1, engine_2, execute_type='PARALLEL')
.
.

await agent.add(engine_3, engine_4, execute_type='PARALLEL')
.
.

# Engines execution will be in following order
# [[agent_1, engine_2, engine_3, engine_4]]
```

### Mixed with Sequence and Parallel

```python theme={null}
from superagentx.agent import agent

agent = Agent(
    ...
    engines=[engine_1, [engine_2, engine_3], engine_4 ... engine_n],
    ...
)

# Engines execution will be in following order
# [engine_1, [engine_2, engine_3], engine_4, ... engine_nm]]
```

#### Alternate way of configure

```python theme={null}
from superagentx.agent import agent

agent = Agent(
    ...,
    ...
)

await agent.add(engine_1, engine_2, execute_type='SEQUENCE')
.
.
.
await agent.add(engine_3, engine_4, execute_type='PARALLEL')
.
.

# Engines execution will be in following order
# [engine_1, engine_2, [engine_3, engine_4]]
```

## Task Agent

In SuperAgentX, a task agent is a focused, self-contained component that executes a complete workflow from start to
finish. It receives an input or trigger, applies decision logic, and uses SuperAgentX handlers and tools to interact
with external systems such as APIs, databases, or messaging services. Task agents are typically asynchronous and
event-driven, enabling reliable automation of monitoring, processing, and orchestration tasks with minimal human
intervention.

```python theme={null}
    task_agent = Agent(engines=[engine])
```

## Browser Agent

In SuperAgentX, a browser agent is a specialized agent designed to interact with web interfaces just like a human user.
It can navigate pages, fill forms, click buttons, extract data, and handle multi-step web workflows using a controlled
browser environment. Browser agents are used when APIs are unavailable or insufficient, enabling automated web actions
such as scraping, verification, onboarding, and portal-based operations within a larger task workflow.

```python theme={null}
    browser_agent = Agent(
        name="Review & Pay Agent",
        role="Browser Payment Executor",
        goal="Review checkout and pay using credit card",
        llm=llm,
        human_approval=True,   # governance point
        prompt_template=browser_prompt,
        engines=[browser_engine],
        max_retry=2
    )
```
