# Lagent

A lightweight Python framework for building LLM-based agents, modeled on neural-network-style layers where agents pass typed messages and automatically record them to memory.

Lagent is a lightweight framework for building agents backed by large language models. It borrows its design philosophy from PyTorch: agents are like neural network layers, and building a multi-agent application means creating those layers and defining how messages pass between them.

Agents communicate using a typed message object, and every message an agent sends or receives during a forward pass is added to that agent's memory automatically, which can be inspected or dumped to a dictionary. A default aggregator assembles memory and formats it for a chosen LLM's chat interface, such as the OpenAI message format, and custom aggregators can implement few-shot prompting or other assembly logic. A tool parser extracts structured tool calls, such as a code interpreter invocation, from a model's raw text output.

It is installed from source with pip and is licensed under Apache-2.0.

Website: https://github.com/InternLM/lagent
