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

AttributeParametersDescription
GoalgoalThe primary objective or goal that the engine is designed to achieve.
RoleroleThe role or function that the engine will assume in its operations.
LLM ClientllmInterface for communicating with the large language model (LLM).
Prompt Templateprompt_templateDefines the structure and format of prompts sent to the LLM using PromptTemplate.
Agent ID (optional)agent_idA 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)nameAn optional name for the engine, providing a more friendly reference for display or logging purposes.
Description (optional)descriptionAn optional description that provides additional context or details about the engine’s purpose and capabilities.
Engines (optional)enginesA 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.
Output Format (optional)output_formatSpecifies the desired format for the engine’s output. This can dictate how results are structured and presented.
Max Retry (optional)max_retryThe 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.
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.

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

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.

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

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

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

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]]