Skip to main content

Create an Agentic Network

In this guide, we'll learn how to create an Agentic Network using the Svahnar Agentic AI Framework. This network will consist of multiple agents working together to perform complex tasks, such as fetching stock market news and sending SMS notifications. We'll walk through the YAML configuration step by step, explaining each component and how they interconnect.

Example YAML Configuration

Below is the example YAML configuration for the Agentic Network:

create_vertical_agent_network:
agent-1:
agent_name: "Stock_news_searcher"
LLM_config:
params:
model: "gpt-4o-mini"
temperature: 0.0
max_tokens: 1000
request_timeout: 600
tools:
tool_assigned:
- name: "YahooFinanceNewsTool"
agent_function:
- "Your function is to search the web or the internet for the latest news about given companies and the stock market, including all relevant news articles and official filings."
incoming_edge:
- "my_supervisor"
outgoing_edge:
- "my_supervisor"

agent-2:
agent_name: "sms_sender"
LLM_config:
params:
model: "gpt-4o-mini"
temperature: 0.0
max_tokens: 1000
request_timeout: 600
tools:
tool_assigned:
- name: "Twilio_sms"
config:
to: "<recipient_phone_number>"
from_: "<twilio_phone_number>"
agent_function:
- "You can send SMS messages to the user using Twilio."
incoming_edge:
- "my_supervisor"
outgoing_edge:
- "my_supervisor"

agent-3:
agent_name: "my_supervisor"
Role: "supervisor"
LLM_config:
params:
model: "gpt-4o-mini"
temperature: 0.0
max_tokens: 1000
request_timeout: 600
agent_function:
- "You are the supervisor of the agents defined in outgoing edges."
incoming_edge:
- "Start"
- "Stock_news_searcher"
- "sms_sender"
outgoing_edge:
- "Stock_news_searcher"
- "sms_sender"

This configuration defines an Agentic Network with three agents:

  • agent-1 ("Stock_news_searcher"): Searches for the latest stock market news.
  • agent-2 ("sms_sender"): Sends SMS messages with the news updates.
  • agent-3 ("my_supervisor"): Supervises the agents and coordinates their activities.

Initialize the Agentic Network

Begin by defining the top-level key create_vertical_agent_network to initialize the Agentic Network. Under this key, you'll define each agent with a unique identifier.

create_vertical_agent_network:
agent-1:
agent_name: "Stock_news_searcher"
agent-2:
agent_name: "sms_sender"
agent-3:
agent_name: "my_supervisor"
Role: "supervisor"

This sets up the basic structure of your network, establishing each agent by a unique agent_name.

The Role of "supervisor" for my_supervisor indicates that this agent oversees and coordinates other agents.

For detailed information, refer to the Initialization Documentation.

Configure LLMs for Each Agent

Each agent requires an LLM configuration to handle reasoning:

LLM_config:
params:
model: "gpt-4o-mini"
temperature: 0.0
max_tokens: 1000
request_timeout: 600
  • model: Indicates the model variant to use.
  • temperature: Controls output randomness; 0.0 ensures deterministic responses.
  • max_tokens: Sets the maximum length of the response.
  • request_timeout: The maximum time to wait for a response from the LLM.

Apply this configuration to each agent to ensure consistent reasoning capabilities.

For more details, visit the LLM Configuration Documentation.

Assign Tools to Agents

Agents can be equipped with tools to enhance their functionality.

  • Stock_news_searcher uses the YahooFinanceNewsTool to fetch financial news.

    tools:
    tool_assigned:
    - name: "YahooFinanceNewsTool"
  • sms_sender uses the Twilio_sms tool to send SMS messages.

    tools:
    tool_assigned:
    - name: "Twilio_sms"
    config:
    to: "<recipient_phone_number>"
    from_: "<twilio_phone_number>"

    Note: Replace <recipient_phone_number> and <twilio_phone_number> with actual phone numbers formatted with the country code (e.g., "+1234567890").

These tools enable agents to interact with external services, such as fetching data or communicating with users.

For additional information, check out the Tools Documentation.

Define Agent Functions

Specify the purpose and role of each agent using agent_function and, if applicable, Role.

  • Stock_news_searcher:

    agent_function:
    - "Your function is to search the web or the internet for the latest news about given companies and the stock market, including all relevant news articles and official filings."
  • sms_sender:

    agent_function:
    - "You can send SMS messages to the user using Twilio."
  • my_supervisor:

    agent_function:
    - "You are the supervisor of the agents defined in outgoing edges."

Explore more about defining agent functions at Agent Function Documentation.

Establish Inter-Agent Communication with Edges

Configure how agents communicate and trigger each other using incoming_edge and outgoing_edge.

  • Stock_news_searcher:

    incoming_edge:
    - "my_supervisor"
    outgoing_edge:
    - "my_supervisor"
  • sms_sender:

    incoming_edge:
    - "my_supervisor"
    outgoing_edge:
    - "my_supervisor"
  • my_supervisor:

    incoming_edge:
    - "Start"
    - "Stock_news_searcher"
    - "sms_sender"
    outgoing_edge:
    - "Stock_news_searcher"
    - "sms_sender"

Explanation:

  • Incoming Edges: Define which agents or signals trigger this agent.
  • Outgoing Edges: Define which agents this agent can communicate with after execution.

The supervisor agent (my_supervisor) starts the process and coordinates between the agents.

Learn more about edges at the Incoming and Outgoing Edges Documentation.

Finalize the YAML Configuration

Combine all the components to finalize your Agentic Network configuration:

create_vertical_agent_network:
agent-1:
agent_name: "Stock_news_searcher"
LLM_config:
params:
model: "gpt-4o-mini"
temperature: 0.0
max_tokens: 1000
request_timeout: 600
tools:
tool_assigned:
- name: "YahooFinanceNewsTool"
agent_function:
- "Your function is to search the web or the internet for the latest news about given companies and the stock market, including all relevant news articles and official filings."
incoming_edge:
- "my_supervisor"
outgoing_edge:
- "my_supervisor"

agent-2:
agent_name: "sms_sender"
LLM_config:
params:
model: "gpt-4o-mini"
temperature: 0.0
max_tokens: 1000
request_timeout: 600
tools:
tool_assigned:
- name: "Twilio_sms"
config:
to: "<recipient_phone_number>"
from_: "<twilio_phone_number>"
agent_function:
- "You can send SMS messages to the user using Twilio."
incoming_edge:
- "my_supervisor"
outgoing_edge:
- "my_supervisor"

agent-3:
agent_name: "my_supervisor"
Role: "supervisor"
LLM_config:
params:
model: "gpt-4o-mini"
temperature: 0.0
max_tokens: 1000
request_timeout: 600
agent_function:
- "You are the supervisor of the agents defined in outgoing edges."
incoming_edge:
- "Start"
- "Stock_news_searcher"
- "sms_sender"
outgoing_edge:
- "Stock_news_searcher"
- "sms_sender"

Your Agentic Network is now fully configured and ready to deploy. The agents will work together as follows:

  • The supervisor agent initiates the process upon the Start signal.
  • It delegates tasks to the Stock_news_searcher and sms_sender agents through the specified edges.
  • The Stock_news_searcher retrieves the latest stock market news.
  • The sms_sender sends the news updates via SMS to the specified recipient.

By following these steps, you've successfully created an Agentic Network composed of multiple agents collaborating to perform complex tasks. This setup can be extended or modified to suit different use cases, demonstrating the flexibility and power of the Svahnar Agentic AI Framework.