
LightAgent
LightAgent: Lightweight AI agent framework with memory, tools & tree-of-thought. Supports multi-agent collaboration, self-learning, and major LLMs (OpenAI/DeepSeek/Qwen). Open-source with MCP/SSE protocol integration.
Stars: 292

LightAgent is a lightweight, open-source Agentic AI development framework with memory, tools, and a tree of thought. It supports multi-agent collaboration, autonomous learning, tool integration, complex task handling, and multi-model support. It also features a streaming API, tool generator, agent self-learning, adaptive tool mechanism, and more. LightAgent is designed for intelligent customer service, data analysis, automated tools, and educational assistance.
README:
LightAgent is an extremely lightweight active Agentic Framework with memory (mem0
), tools (Tools
), and a tree of thought (ToT
), and it is completely open source. It supports simpler multi-agent collaboration than OpenAI Swarm, allowing you to build self-learning agents in just one step, and supports connecting to the MCP protocol via stdio and sse. The underlying models support OpenAI, Zhiyuan ChatGLM, DeepSeek, Jieyue Xingchen, Qwen Tongyi Qianwen large models, and more. At the same time, LightAgent supports OpenAI streaming format API service output, seamlessly integrating with major mainstream Chat frameworks. 🌟
- Lightweight and Efficient 🚀: Minimalist design, quick deployment, suitable for various application scenarios. (No LangChain, No LlamaIndex) 100% Python implementation, no additional dependencies, core code is only 1000 lines, fully open source.
-
Memory Support 🧠: Supports custom long-term memory for each user, natively supporting the
mem0
memory module, automatically managing user personalized memory during conversations, making agents smarter. - Autonomous Learning 📚️: Each agent possesses autonomous learning capabilities, and admins with permissions can manage each agent.
-
Tool Integration 🛠️: Support for custom tools (
Tools
) and MCP tool integration, flexible expansion to meet diverse needs. -
Complex Goals 🌳: Built-in Tree of Thought (
ToT
) module with reflection, supporting complex task decomposition and multi-step reasoning, enhancing task processing capabilities. - Multi-Agent Collaboration 🤖: Simpler to implement multi-agent collaboration than Swarm, with built-in LightSwarm for intent recognition and task delegation, enabling smarter handling of user input and delegating tasks to other agents as needed.
- Independent Execution 🤖: Tasks and tool calls are completed autonomously without human intervention.
- Multi-Model Support 🔄: Compatible with OpenAI, Zhipu ChatGLM, Baichuan Large Model, StepFun, DeepSeek, Qwen series large models.
- Streaming API 🌊: Supports OpenAI streaming format API service output, seamlessly integrates with mainstream chat frameworks, enhancing user experience.
- Tool Generator 🚀: Just provide your API documentation to the [Tool Generator], which will automatically create exclusive tools for you, allowing you to quickly build hundreds of personalized custom tools in just 1 hour to improve efficiency and unleash your creative potential.
- Agent Self-Learning 🧠️: Each agent has its own scene memory capabilities and the ability to self-learn from user conversations.
- Adaptive Tool Mechanism 🛠️: Supports adding an unlimited number of tools, allowing the large model to first select a candidate tool set from thousands of tools, filtering irrelevant tools before submitting context to the large model, significantly reducing token consumption.
-
[2025-09-16] Our paper is now available as a preprint on arXiv: https://arxiv.org/pdf/2509.09292. We invite the research community to read and cite our work.
- [2025-06-12] We are pleased to announce the official release of LightAgent v0.4.0! This version upgrade brings architectural improvements, with significant enhancements in performance, stability, and maintainability.
- [2025-05-05] LightAgent v0.3.3 Released: Deep Langfuse Logging Integration, Enhanced Context Management and Tool Invocation Stability View
- [2025-04-21] LightAgent v0.3.2 adds an adaptive Tools mechanism, supports unlimited intelligent tool filtering, reduces Token consumption by 80%, and improves response speed by 52%! View
- [2025-04-01] LightAgent v0.3.0 Support browser interaction browser_use and fully supports the MCP protocol, enabling collaborative work with multiple models and tools to achieve more efficient handling of complex tasks.View MCP release introduction.>>
- [2025-02-19] LightAgent v0.2.7 supports deepseek-r1 model for tot now.Significantly enhances the multi-tool planning capability for complex tasks.
- [2025-02-06] LightAgent version 0.2.5 is released now.
- [2025-01-20] LightAgent version 0.2.0 is released now.
- [2025-01-05] LightAgent version 0.1.0 is released now.
- Agent Collaborative Communication 🛠️: Agents can also share information and transmit messages, achieving complex information communication and task collaboration.
- Agent Assessment 📊: Built-in agent assessment tool for conveniently evaluating and optimizing the agents you build, aligning with business scenarios, and continuously improving intelligence levels.
The Thought Flow method effectively addresses challenges in complex scenarios through systematic, structured, and flexible thinking processes. Here are the specific implementation steps:
Problem Definition: Clarify the core problems and objectives.
Information Collection: Systematically gather relevant information and data.
Problem Decomposition: Break down complex problems into multiple subproblems or modules.
Multi-dimensional Analysis: Analyze each subproblem from different angles and levels.
Establish Connections: Identify the relationships and dependencies between subproblems.
Generate Solutions: Propose possible solutions for each subproblem.
Evaluation and Selection: Assess the feasibility and impact of each solution, choosing the best one.
Implementation and Feedback: Implement the selected solution and adjust based on feedback.
- Open Source and Free 💖: Fully open source, community-driven, continuously updated, contributions are welcome!
- Easy to Get Started 🎯: Detailed documentation, rich examples, quick to get started, easy integration into your project.
- Community Support 👥: An active developer community ready to assist and provide answers at any time.
- High Performance ⚡: Optimized design, efficient operation, meeting high concurrency requirements.
pip install lightagent
(Optional installation) Install the Mem0 package via pip:
pip install mem0ai
Alternatively, you can use Mem0 on a hosted platform by clicking here.
from LightAgent import LightAgent
# Initialize Agent
agent = LightAgent(model="gpt-4.1", api_key="your_api_key", base_url="your_base_url")
# Run Agent
response = agent.run("Hello, who are you?")
print(response)
from LightAgent import LightAgent
# Initialize Agent
agent = LightAgent(
role="Please remember that you are LightAgent, a useful assistant that helps users use multiple tools.", # system role description
model="gpt-4.1", # Supported models: openai, chatglm, deepseek, qwen, etc.
api_key="your_api_key", # Replace with your large model provider API Key
base_url="your_base_url", # Replace with your large model provider api url
)
# Run Agent
response = agent.run("Who are you?")
print(response)
from LightAgent import LightAgent
# Define Tool
def get_weather(city_name: str) -> str:
"""
Get the current weather for `city_name`
"""
return f"Query result: {city_name} is sunny."
# Define tool information inside the function
get_weather.tool_info = {
"tool_name": "get_weather",
"tool_description": "Get current weather information for the specified city.",
"tool_params": [
{"name": "city_name", "description": "The name of the city to query", "type": "string", "required": True},
]
}
tools = [get_weather]
# Initialize Agent
agent = LightAgent(model="gpt-4.1", api_key="your_api_key", base_url="your_base_url", tools=tools)
# Run Agent
response = agent.run("Please check the weather in Shanghai.")
print(response)
Supports an unlimited number of customizable tools.
Multiple tool examples: tools = [search_news, get_weather, get_stock_realtime_data, get_stock_kline_data]
LightAgent supports external extensions of the mem0
memory module, automating context memory and historical record management without requiring developers to manually trigger memory addition and retrieval. With the memory module, the agent can maintain contextual consistency across multiple rounds of dialogue.
# Enable Memory Module
# Or use a custom memory module, here is an example with mem0 https://github.com/mem0ai/mem0/
from mem0 import Memory
from LightAgent import LightAgent
import os
from loguru import logger
class CustomMemory:
def __init__(self):
self.memories = []
os.environ["OPENAI_API_KEY"] = "your_api_key"
os.environ["OPENAI_API_BASE"] = "your_base_url"
# Initialize Mem0
config = {
"version": "v1.1"
}
# Use qdrant as a vector database for storing memories in mem0, change config to the code below
# config = {
# "vector_store": {
# "provider": "qdrant",
# "config": {
# "host": "localhost",
# "port": 6333,
# }
# },
# "version": "v1.1"
# }
self.m = Memory.from_config(config_dict=config)
def store(self, data: str, user_id):
"""Store memory. Developers can modify the internal implementation of the storage method; the current example is the mem0 method for adding memory."""
result = self.m.add(data, user_id=user_id)
return result
def retrieve(self, query: str, user_id):
"""Retrieve related memory. Developers can modify the internal implementation of the retrieval method; the current example is the mem0 method for searching memory."""
result = self.m.search(query, user_id=user_id)
return result
agent = LightAgent(
role="Please remember that you are LightAgent, a useful assistant to help users use multiple tools.", # system role description
model="gpt-4.1", # Supported models: openai, chatglm, deepseek, qwen, etc.
api_key="your_api_key", # Replace with your large model provider API Key
base_url="your_base_url", # Replace with your large model provider api url
memory=CustomMemory(), # Enable memory function
tree_of_thought=False, # Enable Chain of Thought
)
# Memory-enabled test & if tools need to be added, you can add tools to the agent for memory-enabled tool calls
user_id = "user_01"
logger.info("\n=========== next conversation ===========")
query = "Introduce me to the attractions in Sanya. Many of my friends have traveled to Sanya, and I want to visit too."
print(agent.run(query, stream=False, user_id=user_id))
logger.info("\n=========== next conversation ===========")
query = "Where should I travel?"
print(agent.run(query, stream=False, user_id=user_id))
Output as follows:
=========== next conversation ===========
2025-01-01 21:55:15.886 | INFO | __main__:run_conversation:115 -
Starting to think about the question: Introduce me to the attractions in Sanya, many of my friends have traveled to Sanya, and I want to visit too.
2025-01-01 21:55:28.676 | INFO | __main__:run_conversation:118 - Final Reply:
Sanya is a popular tourist city in Hainan Province, China, known for its beautiful beaches, tropical climate, and rich tourist resources. Here are some attractions worth visiting in Sanya:
1. **Yalong Bay**: Known as the "Hawaii of the East," it has a long beach and clear waters, ideal for swimming, diving, and sunbathing.
2. **Tianya Haijiao**: This is a famous cultural landscape, attracting tourists with its magnificent sea view and romantic legends. The giant rocks here are inscribed with the words "Tianya" and "Haijiao," symbolizing eternal love.
3. **Nanshan Cultural Tourism Zone**: Here there is a 108-meter-tall Nanshan Sea Guanyin statue, the highest sea Guanyin statue in the world. Visitors can experience Buddhist culture and visit temples and gardens.
4. **Wuzhizhou Island**: This small island is known for its pristine natural scenery and rich water activities. Visitors can engage in diving, snorkeling, and sea fishing among other activities.
5. **Dadonghai**: This is a beach located in Sanya city, favored by tourists for its convenient transportation and vibrant nightlife.
6. **Sanya Bay**: It is a 22-kilometer long beach and a great place to watch the sunset. This beach is relatively quiet, suitable for visitors who enjoy tranquility.
7. **Ya Nui National Park**: This is a tropical rainforest park where visitors can experience the natural scenery of tropical rainforests and participate in various adventure activities.
8. **Luohuitou Park**: A park located on a mountaintop, offering a panoramic view of Sanya city and Sanya Bay. There is also a beautiful legend about a deer.
9. **Xidao**: This is a relatively pristine small island attracting tourists with its serene beaches and rich marine life.
10. **Sanya Ancient Love**: This is a large cultural theme park showcasing the history and culture of Hainan through performances and exhibitions.
In addition to the above attractions, Sanya has many other places worth exploring, such as tropical botanical gardens and seafood markets. The local cuisine, especially fresh seafood and tropical fruits, should not be missed. When planning a trip, it is advisable to check the weather forecast and attraction opening times in advance to ensure a pleasant travel experience.
2025-01-01 21:55:28.676 | INFO | __main__:<module>:191 -
=========== next conversation ===========
2025-01-01 21:55:28.676 | INFO | __main__:run_conversation:115 -
Starting to think about the question: Where should I travel?
Relevant memory found:
User wants to travel to Sanya
User's friends have traveled to Sanya.
2025-01-01 21:55:38.797 | INFO | __main__:run_conversation:118 - Final Reply:
Based on previously mentioned information, the user’s friends have already traveled to Sanya, and the user has also expressed interest in going there. Therefore, Sanya might be a suitable travel destination for the user. Here is some travel information about Sanya for the user’s reference:
### Recommended Travel Spots in Sanya:
1. **Yalong Bay**: Known as the "Hawaii of the East," it has beautiful beaches and clear waters, suitable for swimming and sunbathing.
2. **Tianya Haijiao**: This iconic site of Sanya attracts tourists with its unique rocks and romantic legends.
3. **Nanshan Cultural Tourism Area**: It features the famous Nanshan Temple and the 108-meter-high Sea Guanyin statue, an important Buddhist cultural site.
4. **Wuzhizhou Island**: Suitable for diving and marine sports, the island is home to a rich marine ecosystem and coral reefs.
5. **Dadonghai**: A beach within Sanya city, conveniently located and suitable for family and couple visits.
### Other Recommendations:
If the user is already familiar with Sanya or wishes to explore other destinations, here are some other popular travel places:
1. **Guilin**: Known for its unique karst landscape and Lijiang River scenery.
2. **Lijiang**: The ancient town and Jade Dragon Snow Mountain are its main attractions, suitable for those who enjoy history and natural scenery.
3. **Zhangjiajie**: Famous for its unique stone pillars and natural scenery, it is one of the shooting locations for the movie "Avatar."
Users can choose suitable travel destinations based on their interests and schedule. If the user needs more detailed information or assistance in planning the trip, feel free to let us know!
Embrace personalized tool customization (Tools
) and easily integrate your exclusive tools through the tools
method. These tools can be any Python function and support parameter type annotations, ensuring flexibility and accuracy. Additionally, we provide an AI-driven tool generator to help you automatically build tools and unleash creativity.
import requests
from LightAgent import LightAgent
# Define Tool
def get_weather(
city_name: str
) -> str:
"""
Get weather information for a city
:param city_name: Name of the city
:return: Weather information
"""
if not isinstance(city_name, str):
raise TypeError("City name must be a string")
key_selection = {
"current_condition": ["temp_C", "FeelsLikeC", "humidity", "weatherDesc", "observation_time"],
}
try:
resp = requests.get(f"https://wttr.in/{city_name}?format=j1")
resp.raise_for_status()
resp = resp.json()
ret = {k: {_v: resp[k][0][_v] for _v in v} for k, v in key_selection.items()}
except:
import traceback
ret = "Error encountered while fetching weather data!\n" + traceback.format_exc()
return str(ret)
# Define tool information inside the function
get_weather.tool_info = {
"tool_name": "get_weather",
"tool_title": "get weather",
"tool_description": "Get current weather information for the specified city.",
"tool_params": [
{"name": "city_name", "description": "The name of the city to query", "type": "string", "required": True},
]
}
def search_news(
keyword: str,
max_results: int = 5
) -> str:
"""
Search news based on keywords
:param keyword: Search keyword
:param max_results: Maximum number of results to return, default is 5
:return: News search results
"""
results = f"By searching for {keyword}, I've found {max_results} related pieces of information."
return str(results)
# Define tool information inside the function
search_news.tool_info = {
"tool_name": "search_news",
"tool_title": "search news",
"tool_description": "Search news based on keywords.",
"tool_params": [
{"name": "keyword", "description": "Search keyword", "type": "string", "required": True},
{"name": "max_results", "description": "Maximum number of results to return", "type": "int", "required": False},
]
}
def get_user_info(
user_id: str
) -> str:
"""
Get user information
:param user_id: User ID
:return: User information
"""
if not isinstance(user_id, str):
raise TypeError("User ID must be a string")
try:
# Assume using a user info API; this is a sample URL
url = f"https://api.example.com/users/{user_id}"
response = requests.get(url)
response.raise_for_status()
user_data = response.json()
user_info = {
"name": user_data.get("name"),
"email": user_data.get("email"),
"created_at": user_data.get("created_at")
}
except:
import traceback
user_info = "Error encountered while fetching user data!\n" + traceback.format_exc()
return str(user_info)
# Define tool information inside the function
get_user_info.tool_info = {
"tool_name": "get_user_info",
"tool_description": "Retrieve information for the specified user.",
"tool_params": [
{"name": "user_id", "description": "User ID", "type": "string", "required": True},
]
}
# Custom Tools
tools = [get_weather, search_news, get_user_info] # including all tools
# Initialize Agent
# Replace with your model parameters, API key, and base URL
agent = LightAgent(model="gpt-4.1", api_key="your_api_key", base_url="your_base_url", tools=tools)
query = "How is the weather in Sanya today?"
response = agent.run(query, stream=False) # Use agent to run the query
print(response)
The Tool Generator is a module for automatically generating tool code. It can create the corresponding tool code based on the text description provided by users and save it to the specified directory. This functionality is particularly useful for quickly generating API call tools, data processing tools, and more.
Usage example
Here is an example code using the Tool Generator:
import json
import os
import sys
from LightAgent import LightAgent
# Initialize LightAgent
agent = LightAgent(
name="Agent A", # Agent name
instructions="You are a helpful agent.", # Role description
role="Please remember that you are a tool generator; your task is to automatically generate corresponding tool code based on the text description provided by the user and save it to the specified directory. Please ensure that the generated code is accurate, usable, and meets the user's needs.", # Tool generator's role description
model="gpt-4.1", # Replace with your model. Supported models: openai, chatglm, deepseek, qwen, etc.
api_key="your_api_key", # Replace with your API Key
base_url="your_base_url", # Replace with your API URL
)
# Sample text description
text = """
The Sina stock interface provides functionalities for obtaining stock market data, including stock quotes, real-time trading data, and K-line chart data.
Introduction to Sina stock interface functions
1. Get stock quote data:
Realtime quote data: Using the real-time quote API, you can obtain the latest prices, trading volume, and changes for stocks.
Minute line quote data: Using the minute line quote API, you can obtain the minute-by-minute trading data for stocks, including opening price, closing price, highest price, and lowest price.
2. Obtain historical K-line chart data:
K-line chart data: Through the K-line chart API, you can obtain the historical trading data for stocks, including opening price, closing price, highest price, lowest price, trading volume, etc. You can choose different time periods and moving average periods as needed.
Adjusted data: You can choose to retrieve adjusted K-line data, including pre-adjusted and post-adjusted data, for more accurate analysis of stock price changes.
Example of obtaining data from the Sina stock interface
1. Get stock quote data:
API address: http://hq.sinajs.cn/list=[stock_code]
Example: To obtain real-time quote data for the stock code "sh600519" (Kweichow Moutai), you can use the following API address: http://hq.sinajs.cn/list=sh600519
By sending an HTTP GET request to the above API address, you will receive a response containing the real-time data for that stock.
2. Get historical K-line chart data:
API address: http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol=[stock_code]&scale=[time_period]&ma=[average_period]&datalen=[data_length]
Example: To obtain daily K-line chart data for the stock code "sh600519" (Kweichow Moutai), you can use the following API address: http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol=sh600519&scale=240&ma=no&datalen=1023
By sending an HTTP GET request to the above API address, you will receive a response containing the historical K-line chart data for that stock.
"""
# Build the path to the tools directory
project_root = os.path.dirname(os.path.abspath(__file__))
tools_directory = os.path.join(project_root, "tools")
# Create tools directory if it does not exist
if not os.path.exists(tools_directory):
os.makedirs(tools_directory)
print(f"Tools directory has been created: {tools_directory}")
# Use agent to generate tool code
agent.create_tool(text, tools_directory=tools_directory)
After execution, two files will be generated in the tools directory: get_stock_kline_data.py and get_stock_realtime_data.py.
Currently, it is already supported to independently customize the use of the deepseek-r1 model for planning and thinking.The built-in Tree of Thought module supports complex task decomposition and multi-step reasoning. Through the Tree of Thought, the agent can better handle complex tasks.
# Enable Tree of Thought
agent = LightAgent(
model="gpt-4.1",
api_key="your_api_key",
base_url="your_base_url",
tree_of_thought=True, # Enable Tree of Thought
tot_model="gpt-4o",
tot_api_key="sk-uXx0H0B***17778F1", # your deepseek r1 API Key
tot_base_url="https://api.openai.com/v1", # api url
filter_tools=False, # Disable the adaptive tool mechanism
)
After enabling ToT, the adaptive tool mechanism is enabled by default. If you need to disable it, please add the parameter filter_tools=False when initializing LightAgent.
Supports swarm-like multi-agent collaboration, enhancing task processing efficiency. Multiple agents can work together to complete complex tasks.
from LightAgent import LightAgent, LightSwarm
# Set Environment Variables OPENAI_API_KEY and OPENAI_BASE_URL
# The default model uses gpt-4o-mini
# Create an instance of LightSwarm
light_swarm = LightSwarm()
# Create multiple agents
agent_a = LightAgent(
name="Agent A",
instructions="I am Agent A, the front desk receptionist.",
role="Receptionist responsible for welcoming visitors and providing basic information guidance. Before each reply, please state your identity and that you can only guide users to other roles, not directly answer business questions. If you cannot help the user, please respond: Sorry, I am currently unable to assist!"
)
agent_b = LightAgent(
name="Agent B",
instructions="I am Agent B, responsible for the reservation of meeting rooms.",
role="Meeting room reservation administrator in charge of handling reservations, cancellations, and inquiries for meeting rooms 1, 2, and 3."
)
agent_c = LightAgent(
name="Agent C",
instructions="I am Agent C, a technical support specialist, responsible for handling technical issues. Please state your identity before each reply, offering detailed responses to technical inquiries, and guide users to contact higher-level technical support for issues beyond your capability."
)
agent_d = LightAgent(
name="Agent D",
instructions="I am Agent D, an HR specialist, responsible for handling HR-related questions.",
role="HR specialist managing inquiries and processes related to employee onboarding, offboarding, leave, and benefits."
)
# Automatically register agents to the LightSwarm instance
light_swarm.register_agent(agent_a, agent_b, agent_c, agent_d)
# Run Agent A
res = light_swarm.run(agent=agent_a, query="Hello, I am Alice. I need to check if Wang Xiaoming has completed onboarding.", stream=False)
print(res)
Output as follows:
Hello, I am Agent D, the HR specialist. Regarding whether Wang Xiaoming has completed onboarding, I need to check our system records. Please wait a moment.
(Checking system records...)
According to our records, Wang Xiaoming completed his onboarding procedures on January 5, 2025. He has signed all necessary documents and has been assigned an employee number and office location. If you need further details or have any other questions, please feel free to contact the HR department. We are always ready to assist you.
Supports OpenAI streaming format API service output, seamlessly integrating with mainstream chat frameworks.
# Enable streaming output
response = agent.run("Please generate an article about AI.", stream=True)
for chunk in response:
print(chunk)
The Agent possesses a unique scene memory capability, allowing it to accurately retain key information from interactions with users. At the same time, it has a powerful ability to extract knowledge from user dialogues and engage in self-learning, continuously optimizing its understanding and response strategies for various scenarios with each conversation, thereby achieving a continuous improvement in intelligence levels to better meet the diverse needs of users. Through this self-learning mechanism, the Agent can continuously adapt to complex and changing task scenarios, providing users with higher quality, more efficient, and personalized services.
agent = LightAgent(
name="Agent A", # Agent name
instructions="You are a helpful agent.", # Role description
role="Please remember that you are LightAgent, a useful assistant to help users use multiple tools.", # system role description
model="gpt-4.1", # Supported models: openai, chatglm, deepseek, qwen, etc. qwen-turbo-2024-11-01 \ step-1-flash
api_key="your_api_key", # Replace with your API Key
base_url="http://your_base_url/v1", # API URL
memory=CustomMemory(), # Enable memory function
self_learning=True, # Enable agent self-learning
debug=True,
log_level="DEBUG",
log_file="example.log"
)
user_id = "test_user_1"
query = "I now have a procurement payment that needs to be transferred. What is my approval process?"
agent.run(query, stream=False, user_id=user_id)
query = "Please remember: According to the new company regulations, starting from January 2025, all procurement payments must first be signed by Manager Ding, who is responsible for procurement, then submitted to the finance manager for approval. After the finance manager's approval, the general manager of the company must also approve before the cashier can make the payment."
agent.run(query, stream=False, user_id=user_id)
user_id = "test_user_2"
query = "Hello, I have a procurement payment to transfer to the other party. How do I apply for the transfer?"
agent.run(query, stream=False, user_id=user_id)
LightAgent integrates with the Langfuse open-source platform, providing full-link monitoring and log analysis capabilities, real-time tracking of key metrics such as token consumption and response latency, and supporting interactive data management and version control. The platform's visualization analysis features clearly display the core decision-making processes of the Agent, such as context retrieval and tool invocation, and fully record user interaction flows.
from LightAgent import LightAgent
tracetools = {
"TraceTool": "langfuse",
"TraceToolConfig": {
"langfuse_enabled": True,
"langfuse_host": "https://cloud.langfuse.com",
"langfuse_public_key": "pk-lf-9fedb073-a*86-4**5-b**2-52****1b1**7",
"langfuse_secret_key": "sk-lf-27bdbdec-c**6-4**3-a**2-28**0140**c7"
}
}
agent = LightAgent(
name="Agent A", # Agent Name
instructions="You are a helpful agent.", # Role Description
role="Please remember that you are LightAgent, a useful assistant to help users use multiple tools.", # system role description
model="gpt-4o-mini", # Supported models: openai, chatglm, deepseek, qwen, etc. qwen-turbo-2024-11-01 \ step-1-flash
api_key="your_api_key", # Replace with your API Key
base_url="http://your_base_url/v1", # API URL
debug=True,
log_level="DEBUG",
log_file="example.log",
tracetools=tracetools
)
The LLM call logs tracked by Langfuse are shown in the figure below:
Built-in agent assessment tool for conveniently evaluating and optimizing agent performance.
Compatible with various large models, including OpenAI, Zhipu ChatGLM, DeepSeek, Qwen series large models.
OpenAI Series
- gpt-3.5-turbo
- gpt-4
- gpt-4o
- gpt-4o-mini
- gpt-4.1
- gpt-4.1-mini
- gpt-4.1-nano
ChatGLM
- GLM-4.5
- GLM-4.5-Air
- GLM-4.5-X
- GLM-4.5-AirX
- GLM-4.5-Flash
- GLM-4-Plus
- GLM-4-Air-0111
- GLM-4-Flash
- GLM-4-FlashX
- GLM-4-alltools
- GLM-4
- GLM-3-Turbo
- ChatGLM3-6B
- GLM-4-9B-Chat
DeepSeek Series
- DeepSeek-r1
- DeepSeek-v3
stepfun
- step-1-8k
- step-1-32k
- step-1-128k (issues with multi-tool calls)
- step-1-256k (issues with multi-tool calls)
- step-1-flash (recommended, cost-effective)
- step-2-16k (issues with multi-tool calls)
Qwen Series
- qwen-plus-2024-11-25
- qwen-plus-2024-11-27
- qwen-plus-1220
- qwen-plus
- qwen-plus-latest
- qwen2.5-72b-instruct
- qwen2.5-32b-instruct
- qwen2.5-14b-instruct
- qwen2.5-7b-instruct
- qwen-turbo-latest
- qwen-turbo-2024-11-01
- qwen-turbo
- qwen-long
- qwq-32b
- qwen3-0.6b
- qwen3-1.7b
- qwen3-4b
- qwen3-8b
- qwen3-14b
- qwen3-32b
- qwen3-30b-a3b
- qwen3-235b-a22b
- Qwen3-30B-A3B-Thinking-2507
- Qwen3-30B-A3B-Instruct-2507
- Intelligent Customer Service: Provide efficient customer support through multi-turn dialogue and tool integration.
- Data Analysis: Use Tree of Thought and multi-agent collaboration to handle complex data analysis tasks.
- Automated Tools: Quickly build customized tools through automated tool generation.
- Educational Assistance: Provide personalized learning experiences using memory modules and streaming API.
We welcome any form of contribution! Whether it's code, documentation, tests, or feedback, it's a tremendous help to the project. If you have great ideas or find bugs, please submit an Issue or Pull Request. Here are the contribution steps:
-
Fork this project: Click the
Fork
button at the top right corner to copy the project to your GitHub repository. -
Create a branch: Create your development branch locally:
git checkout -b feature/YourFeature
-
Submit changes: After finishing development, submit your changes:
git commit -m 'Add some feature'
-
Push the branch: Push the branch to your remote repository:
git push origin feature/YourFeature
- Submit Pull Request: Submit a Pull Request on GitHub and describe your changes.
We will review your contributions promptly. Thank you for your support! ❤️
Shanghai Wanxing AI and Professor Zhang Liwen's research group from the School of Statistics and Data Science at Shanghai University of Finance and Economics have jointly open-sourced a new generation intelligent agent framework called LightAgent.The development and implementation of LightAgent owe much to the inspiration and support from the following open-source projects, especially the outstanding projects and teams:
- MCP: Thanks to mcp for providing the Model Context Protocol (MCP), which offers a standardized infrastructure for the dynamic tool integration of LightAgent.
- mem0: Thanks to mem0 for providing the memory module, which offers strong support for LightAgent's context management.
- Swarm: Thanks to Swarm for designing ideas for multi-agent collaboration, laying the groundwork for LightAgent's multi-agent features.
- ChatGLM3: Thanks to ChatGLM3 for providing high-performance Chinese large model support and design inspiration.
- Qwen: Thanks to Qwen for providing high-performance Chinese large model support.
- DeepSeek-V3: Thanks to DeepSeek-V3 for providing high-performance Chinese large model support.
- StepFun: Thanks to step for providing high-performance Chinese large model support.
LightAgent is licensed under the Apache 2.0 License. You can freely use, modify, and distribute this project, but please adhere to the terms of the license.
If you have any questions or suggestions, please feel free to contact Wanxing AI or Professor Zhang Liwen from the School of Statistics and Data Science at Shanghai University of Finance and Economics:
- Wanxing AI Email: [email protected]
- Professor Zhang Liwen Email: [email protected]
- GitHub Issues: https://github.com/wxai-space/lightagent/issues
We look forward to your feedback and work together to make LightAgent even stronger! 🚀
- More Tools 🛠️: Continuously integrating more practical tools to meet various scenario needs.
- More Model Support 🔄: Continuously expanding support for more large models, catering to diverse application scenarios.
- More Features 🎯: More practical features, ongoing updates, stay tuned!
- More Documentation 📚: Detailed documentation with abundant examples for quick onboarding and easy integration into your projects.
- More Community Support 👥: An active developer community ready to provide help and answers anytime.
- More Performance Optimization ⚡: Continuously optimizing performance to meet high concurrency demands.
- More Open Source Contributions 🌟: Contributions in code are welcome for building a better LightAgent together!
LightAgent - Making intelligence lighter, making the future simpler. 🌈
LightAgent —— A lightweight, flexible, and powerful active Agent framework that assists you in quickly building intelligent applications!
@misc{2509.09292,
Author = {Weige Cai and Tong Zhu and Jinyi Niu and Ruiqi Hu and Lingyao Li and Tenglong Wang and Xiaowu Dai and Weining Shen and Liwen Zhang},
Title = {LightAgent: Production-level Open-source Agentic AI Framework},
Year = {2025},
Eprint = {arXiv:2509.09292},
Eprinttype = {arXiv},
Eprintclass = {cs.AI},
Url = {https://arxiv.org/abs/2509.09292},
Doi = {10.48550/arXiv.2509.09292},
Note = {Submitted on 11 Sep 2025}
}
For Tasks:
Click tags to check more tools for each tasksFor Jobs:
Alternative AI tools for LightAgent
Similar Open Source Tools

LightAgent
LightAgent is a lightweight, open-source Agentic AI development framework with memory, tools, and a tree of thought. It supports multi-agent collaboration, autonomous learning, tool integration, complex task handling, and multi-model support. It also features a streaming API, tool generator, agent self-learning, adaptive tool mechanism, and more. LightAgent is designed for intelligent customer service, data analysis, automated tools, and educational assistance.

zenml
ZenML is an extensible, open-source MLOps framework for creating portable, production-ready machine learning pipelines. By decoupling infrastructure from code, ZenML enables developers across your organization to collaborate more effectively as they develop to production.

marly
Marly is a tool that allows users to search for and extract context-specific data from various types of documents such as PDFs, Word files, Powerpoints, and websites. It provides the ability to extract data in structured formats like JSON or Markdown, making it easy to integrate into workflows. Marly supports multi-schema and multi-document extraction, offers built-in caching for rapid repeat extractions, and ensures no vendor lock-in by allowing flexibility in choosing model providers.

AutoMathText
AutoMathText is an extensive dataset of around 200 GB of mathematical texts autonomously selected by the language model Qwen-72B. It aims to facilitate research in mathematics and artificial intelligence, serve as an educational tool for learning complex mathematical concepts, and provide a foundation for developing AI models specialized in processing mathematical content.

viitor-voice
ViiTor-Voice is an LLM based TTS Engine that offers a lightweight design with 0.5B parameters for efficient deployment on various platforms. It provides real-time streaming output with low latency experience, a rich voice library with over 300 voice options, flexible speech rate adjustment, and zero-shot voice cloning capabilities. The tool supports both Chinese and English languages and is suitable for applications requiring quick response and natural speech fluency.

exospherehost
Exosphere is an open source infrastructure designed to run AI agents at scale for large data and long running flows. It allows developers to define plug and playable nodes that can be run on a reliable backbone in the form of a workflow, with features like dynamic state creation at runtime, infinite parallel agents, persistent state management, and failure handling. This enables the deployment of production agents that can scale beautifully to build robust autonomous AI workflows.

agents
The LiveKit Agent Framework is designed for building real-time, programmable participants that run on servers. Easily tap into LiveKit WebRTC sessions and process or generate audio, video, and data streams. The framework includes plugins for common workflows, such as voice activity detection and speech-to-text. Agents integrates seamlessly with LiveKit server, offloading job queuing and scheduling responsibilities to it. This eliminates the need for additional queuing infrastructure. Agent code developed on your local machine can scale to support thousands of concurrent sessions when deployed to a server in production.

premsql
PremSQL is an open-source library designed to help developers create secure, fully local Text-to-SQL solutions using small language models. It provides essential tools for building and deploying end-to-end Text-to-SQL pipelines with customizable components, ideal for secure, autonomous AI-powered data analysis. The library offers features like Local-First approach, Customizable Datasets, Robust Executors and Evaluators, Advanced Generators, Error Handling and Self-Correction, Fine-Tuning Support, and End-to-End Pipelines. Users can fine-tune models, generate SQL queries from natural language inputs, handle errors, and evaluate model performance against predefined metrics. PremSQL is extendible for customization and private data usage.

weave
Weave is a toolkit for developing Generative AI applications, built by Weights & Biases. With Weave, you can log and debug language model inputs, outputs, and traces; build rigorous, apples-to-apples evaluations for language model use cases; and organize all the information generated across the LLM workflow, from experimentation to evaluations to production. Weave aims to bring rigor, best-practices, and composability to the inherently experimental process of developing Generative AI software, without introducing cognitive overhead.

effective_llm_alignment
This is a super customizable, concise, user-friendly, and efficient toolkit for training and aligning LLMs. It provides support for various methods such as SFT, Distillation, DPO, ORPO, CPO, SimPO, SMPO, Non-pair Reward Modeling, Special prompts basket format, Rejection Sampling, Scoring using RM, Effective FAISS Map-Reduce Deduplication, LLM scoring using RM, NER, CLIP, Classification, and STS. The toolkit offers key libraries like PyTorch, Transformers, TRL, Accelerate, FSDP, DeepSpeed, and tools for result logging with wandb or clearml. It allows mixing datasets, generation and logging in wandb/clearml, vLLM batched generation, and aligns models using the SMPO method.

Adaptive-MT-LLM-Fine-tuning
The repository Adaptive-MT-LLM-Fine-tuning contains code and data for the paper 'Fine-tuning Large Language Models for Adaptive Machine Translation'. It focuses on enhancing Mistral 7B, a large language model, for real-time adaptive machine translation in the medical domain. The fine-tuning process involves using zero-shot and one-shot translation prompts to improve terminology and style adherence. The repository includes training and test data, data processing code, fuzzy match retrieval techniques, fine-tuning methods, conversion to CTranslate2 format, tokenizers, translation codes, and evaluation metrics.

MInference
MInference is a tool designed to accelerate pre-filling for long-context Language Models (LLMs) by leveraging dynamic sparse attention. It achieves up to a 10x speedup for pre-filling on an A100 while maintaining accuracy. The tool supports various decoding LLMs, including LLaMA-style models and Phi models, and provides custom kernels for attention computation. MInference is useful for researchers and developers working with large-scale language models who aim to improve efficiency without compromising accuracy.

kaito
KAITO is an operator that automates the AI/ML model inference or tuning workload in a Kubernetes cluster. It manages large model files using container images, provides preset configurations to avoid adjusting workload parameters based on GPU hardware, supports popular open-sourced inference runtimes, auto-provisions GPU nodes based on model requirements, and hosts large model images in the public Microsoft Container Registry. Using KAITO simplifies the workflow of onboarding large AI inference models in Kubernetes.

multi-agent-orchestrator
Multi-Agent Orchestrator is a flexible and powerful framework for managing multiple AI agents and handling complex conversations. It intelligently routes queries to the most suitable agent based on context and content, supports dual language implementation in Python and TypeScript, offers flexible agent responses, context management across agents, extensible architecture for customization, universal deployment options, and pre-built agents and classifiers. It is suitable for various applications, from simple chatbots to sophisticated AI systems, accommodating diverse requirements and scaling efficiently.

semantic-kernel
Semantic Kernel is an SDK that integrates Large Language Models (LLMs) like OpenAI, Azure OpenAI, and Hugging Face with conventional programming languages like C#, Python, and Java. Semantic Kernel achieves this by allowing you to define plugins that can be chained together in just a few lines of code. What makes Semantic Kernel _special_ , however, is its ability to _automatically_ orchestrate plugins with AI. With Semantic Kernel planners, you can ask an LLM to generate a plan that achieves a user's unique goal. Afterwards, Semantic Kernel will execute the plan for the user.

raga-llm-hub
Raga LLM Hub is a comprehensive evaluation toolkit for Language and Learning Models (LLMs) with over 100 meticulously designed metrics. It allows developers and organizations to evaluate and compare LLMs effectively, establishing guardrails for LLMs and Retrieval Augmented Generation (RAG) applications. The platform assesses aspects like Relevance & Understanding, Content Quality, Hallucination, Safety & Bias, Context Relevance, Guardrails, and Vulnerability scanning, along with Metric-Based Tests for quantitative analysis. It helps teams identify and fix issues throughout the LLM lifecycle, revolutionizing reliability and trustworthiness.
For similar tasks

Azure-Analytics-and-AI-Engagement
The Azure-Analytics-and-AI-Engagement repository provides packaged Industry Scenario DREAM Demos with ARM templates (Containing a demo web application, Power BI reports, Synapse resources, AML Notebooks etc.) that can be deployed in a customer’s subscription using the CAPE tool within a matter of few hours. Partners can also deploy DREAM Demos in their own subscriptions using DPoC.

sorrentum
Sorrentum is an open-source project that aims to combine open-source development, startups, and brilliant students to build machine learning, AI, and Web3 / DeFi protocols geared towards finance and economics. The project provides opportunities for internships, research assistantships, and development grants, as well as the chance to work on cutting-edge problems, learn about startups, write academic papers, and get internships and full-time positions at companies working on Sorrentum applications.

tidb
TiDB is an open-source distributed SQL database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads. It is MySQL compatible and features horizontal scalability, strong consistency, and high availability.

zep-python
Zep is an open-source platform for building and deploying large language model (LLM) applications. It provides a suite of tools and services that make it easy to integrate LLMs into your applications, including chat history memory, embedding, vector search, and data enrichment. Zep is designed to be scalable, reliable, and easy to use, making it a great choice for developers who want to build LLM-powered applications quickly and easily.

telemetry-airflow
This repository codifies the Airflow cluster that is deployed at workflow.telemetry.mozilla.org (behind SSO) and commonly referred to as "WTMO" or simply "Airflow". Some links relevant to users and developers of WTMO: * The `dags` directory in this repository contains some custom DAG definitions * Many of the DAGs registered with WTMO don't live in this repository, but are instead generated from ETL task definitions in bigquery-etl * The Data SRE team maintains a WTMO Developer Guide (behind SSO)

mojo
Mojo is a new programming language that bridges the gap between research and production by combining Python syntax and ecosystem with systems programming and metaprogramming features. Mojo is still young, but it is designed to become a superset of Python over time.

pandas-ai
PandasAI is a Python library that makes it easy to ask questions to your data in natural language. It helps you to explore, clean, and analyze your data using generative AI.

databend
Databend is an open-source cloud data warehouse that serves as a cost-effective alternative to Snowflake. With its focus on fast query execution and data ingestion, it's designed for complex analysis of the world's largest datasets.
For similar jobs

sweep
Sweep is an AI junior developer that turns bugs and feature requests into code changes. It automatically handles developer experience improvements like adding type hints and improving test coverage.

teams-ai
The Teams AI Library is a software development kit (SDK) that helps developers create bots that can interact with Teams and Microsoft 365 applications. It is built on top of the Bot Framework SDK and simplifies the process of developing bots that interact with Teams' artificial intelligence capabilities. The SDK is available for JavaScript/TypeScript, .NET, and Python.

ai-guide
This guide is dedicated to Large Language Models (LLMs) that you can run on your home computer. It assumes your PC is a lower-end, non-gaming setup.

classifai
Supercharge WordPress Content Workflows and Engagement with Artificial Intelligence. Tap into leading cloud-based services like OpenAI, Microsoft Azure AI, Google Gemini and IBM Watson to augment your WordPress-powered websites. Publish content faster while improving SEO performance and increasing audience engagement. ClassifAI integrates Artificial Intelligence and Machine Learning technologies to lighten your workload and eliminate tedious tasks, giving you more time to create original content that matters.

chatbot-ui
Chatbot UI is an open-source AI chat app that allows users to create and deploy their own AI chatbots. It is easy to use and can be customized to fit any need. Chatbot UI is perfect for businesses, developers, and anyone who wants to create a chatbot.

BricksLLM
BricksLLM is a cloud native AI gateway written in Go. Currently, it provides native support for OpenAI, Anthropic, Azure OpenAI and vLLM. BricksLLM aims to provide enterprise level infrastructure that can power any LLM production use cases. Here are some use cases for BricksLLM: * Set LLM usage limits for users on different pricing tiers * Track LLM usage on a per user and per organization basis * Block or redact requests containing PIIs * Improve LLM reliability with failovers, retries and caching * Distribute API keys with rate limits and cost limits for internal development/production use cases * Distribute API keys with rate limits and cost limits for students

uAgents
uAgents is a Python library developed by Fetch.ai that allows for the creation of autonomous AI agents. These agents can perform various tasks on a schedule or take action on various events. uAgents are easy to create and manage, and they are connected to a fast-growing network of other uAgents. They are also secure, with cryptographically secured messages and wallets.

griptape
Griptape is a modular Python framework for building AI-powered applications that securely connect to your enterprise data and APIs. It offers developers the ability to maintain control and flexibility at every step. Griptape's core components include Structures (Agents, Pipelines, and Workflows), Tasks, Tools, Memory (Conversation Memory, Task Memory, and Meta Memory), Drivers (Prompt and Embedding Drivers, Vector Store Drivers, Image Generation Drivers, Image Query Drivers, SQL Drivers, Web Scraper Drivers, and Conversation Memory Drivers), Engines (Query Engines, Extraction Engines, Summary Engines, Image Generation Engines, and Image Query Engines), and additional components (Rulesets, Loaders, Artifacts, Chunkers, and Tokenizers). Griptape enables developers to create AI-powered applications with ease and efficiency.