InternLM/lagent

A lightweight framework for building LLM-based agents

What it solves

Lagent is a framework for building multi-agent applications. It simplifies the process of creating agents and defining how they communicate and pass messages, drawing inspiration from the design philosophy of PyTorch to make the workflow intuitive for developers.

How it works

Lagent treats agents and tools as layers in a network, where communication is handled via AgentMessage objects. It manages agent state through a memory system that tracks input and output messages. The framework provides flexible response formatting (via parsers) and a consistent interface for tool calling through ActionExecutor and hooks. To support both rapid prototyping and high-performance deployment, it offers dual synchronous and asynchronous interfaces for all major components (LLMs, actions, and executors).

Who it’s for

Developers building complex AI agent workflows, such as self-refining writers, math solvers that use code interpreters, or multi-agent systems for data collection and visualization.

Highlights

  • PyTorch-inspired design: Uses a layer-like analogy for defining agent workflows and message passing.
  • Dual Interface: Provides both synchronous and asynchronous variants of components for debugging and large-scale inference.
  • Flexible Memory: Built-in session-based memory management to isolate conversations and tool environments.
  • Customizable Aggregators: Allows users to implement custom logic for how messages are assembled and converted for LLM prompts (e.g., few-shot prompting).
  • Integrated Tooling: Includes built-in support for code interpreters (IPython) and web browsers.

Related

  • Project
  • Project
  • Project
  • Project
  • Project