Lagent logo

Lagent

Free

A lightweight framework for building LLM-based agents ![GitHub Repo stars](https://img.shields.io/github/stars/InternLM/lagent?style=social)

FreeFree tier
Type
Open Source
Company
InternLM

About Lagent

Lagent is a lightweight, Pythonic framework for building LLM-based agents, inspired by the design philosophy of PyTorch. It provides a clear message-passing interface using AgentMessage, built-in memory management that tracks conversation history, and customizable message aggregation. The framework is LLM-agnostic, supporting models like Qwen2 and InternLM2 via the VllmModel interface, and allows developers to build multi-agent applications with minimal boilerplate. Lagent is open-source under the InternLM organization on GitHub.

Key Features

Lightweight and Pythonic design inspired by PyTorch
AgentMessage-based communication between agents
Built-in memory management (state dict, reset, inspect)
Customizable message aggregation (DefaultAggregator for OpenAI format)
LLM-agnostic: supports various models via VllmModel (Qwen2, InternLM2, etc.)
Multi-agent application support

Pros & Cons

Pros
  • Lightweight and easy to set up
  • Clear, PyTorch-like API for developers
  • Built-in memory management simplifies conversation tracking
  • Flexible LLM backend integration
Cons
  • Relatively new project with smaller community compared to established frameworks
  • Limited pre-built agent templates or specialized tool-use components
  • Documentation is primarily the README and examples

Best For

Building conversational AI agents with memoryDeveloping multi-agent collaboration systemsPrototyping LLM-based tool-use agentsEducational projects for learning agent architectures

FAQ

What is Lagent?
Lagent is a lightweight open-source framework for building LLM-based agents, developed by the InternLM organization. It uses a PyTorch-inspired design with AgentMessage for communication and built-in memory management.
What LLMs does Lagent support?
Lagent is LLM-agnostic and uses the VllmModel interface. Examples include Qwen2-7B-Instruct and InternLM2, but it can be extended to other models compatible with the VllmModel wrapper.
How does Lagent handle memory?
Both input and output messages are automatically added to the agent's memory each forward pass. Users can inspect the memory via the `.memory` attribute or dump it with `.state_dict()`, and reset it using `.reset()`.