Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
agent-from-scratch is a Python-based repository designed for developers and researchers interested in understanding the inner workings of single and multi-agent systems
Fetched from the repository for this visit.
agent-from-scratch is a Python-based repository for developers and researchers to understand the fundamentals of single and multi-agent systems without going through more dense and sophisticated Agent frameworks such as Langgraph and Autogen. In fact, agent-from-sctach is not even a framework, it is single script repository which you can simply download and meddle with it to understand how agents work.
It is a fork of OpenAI's Swarm, which is already straightforward. However, agent-from-scratch is even simpler, making it easier to quickly start and understand single and multi-agent systems.
It is for software developers and ML Engineers who would like to understand what are agents and how are they built. This is not a Agent framework. This is simply a python script
There is a single script called agent.py in this. It is a very easy read. One can read it and understand what Agents are and how they are built. Once you understand you can either fork this repository or just copy paste the agent.py script and start building your own agents.
git clone https://github.com/hexo-ai/agent-from-scratch.gitconda env create -f environment.yml. Alternatively, you can use a virtual environment..env file by copying the structure from .env.template..env file.conda activate agent-from-scratch or your virtual environment.pip install -r requirements.txt.python single_agent_example.py. This script implements a weather agent with capabilities to send emails.python multi_agent_example.py. This script implements sales and refund agents with capabilities to apply discounts and process refunds.This is the singular script which constructs an Agent. An agent is nothing more nothing lesser than an LLM which can call tools/functions and go in loops to accomplish a goal. Here is an architecture of an Agent.
A User can assign a goal to an agent. An Agent consists of an LLM and the LLM is capable to calling a bunch of tools. The LLM takes up the goal and uses whichever tool, whenever necessary in order to accomplish the goal.
agent.py, you will see a class called Agent which can take up a goal (variable named instructions), an LLM (variable named model) and a bunch of tools (variable named functions).Swarm which contains the logic on how the LLM can calls the tools and accomplish the given goal.class Swarm:
def __init__():
# Implements logic of how llm and tool calling works together
def get_chat_completion():
# Implements LLM completion
def handle_tool_calls():
# Implements tool calling
def handle_function_result():
# processes the tool outptu
def run():
# runs the whole logic of goal -> llm -> tools -> output -> feedback from environment
We have included two examples in this repository: namely, single_agent_example.py and multi_agent_example.py.
In single_agent_example.py, we have a simple implementation of a weather agent. Here are the features of the agent:
In the multi_agent_example.py, we have a simple implementation of a customer bot multi-agent. There are three agents implemented in it, namely: triage_agent, sales_agent and refund agent
Please feel free to fork this repository and create PRs. We are eager to get PRs on the following:
GitHub checked 135h ago - refresh overdue. Recently viewed repositories target hourly refresh.