Lagent Lightweight Agent Framework

A lightweight framework for building LLM-based agents, inspired by PyTorch's design philosophy.

Source repo
InternLM/lagent
Stars
★ 2.3k
Last updated
7mo ago agentrl_rc0
FARS reviewed
Nov 08, 2026
License
Apache-2.0
Primary language
Python

At a glance

How it runs
Library / SDKFramework
Works with
Universal · cross-platformOpenAI API
Cost
Free software; you pay for model usage
Setup effort
Medium · a few setup steps
You'll need
Python 3.8+GitpipShell / CLINetwork accessLocal filesystem
Typical use
Developers needing to quickly build an agent that solves math problems by writing and executing Python code.
Not a fit if
  • Users who want a ready-made GUI or chat bot
  • Teams without GPUs or local model serving resources
Maintenance
No commits for 6+ monthslast commit 2026-04-20latest release agentrl_rc0 (2026-05-19)

What does this agent do, and when should you use it?

Lagent is a lightweight framework for building LLM-based agents, inspired by PyTorch's design philosophy of layers and message passing. It provides an Agent class that communicates via AgentMessage, enabling intuitive workflow construction. The framework supports various LLM backends (e.g., VllmModel, GPTAPI, AsyncGPTAPI) and tools (e.g., IPythonInterpreter, WebBrowser), with synchronous and asynchronous interfaces. Key features include memory management, custom aggregators, flexible output formatting (ToolParser), and tool invocation via ActionExecutor. Installation is straightforward via pip, and examples cover math problem solving, multi-agent blogging, and data visualization. Licensed under Apache-2.0.

Lagent allows users to build agents by defining Agent instances and passing AgentMessage. It supports multiple LLM providers (e.g., VllmModel, GPTAPI) and integrates tools like IPythonInterpreter and WebBrowser. The core flow: Agent receives messages, maintains context via memory, formats messages using an aggregator, calls the LLM for a response, and optionally executes tool calls via ActionExecutor. It provides synchronous and asynchronous variants (e.g., AsyncAgent) and allows custom aggregators, output parsers, and hooks.

  1. Developers needing to quickly build an agent that solves math problems by writing and executing Python code.
  2. Teams aiming to implement multi-agent collaboration, such as a writer and critic improving a blog post.
  3. Researchers requiring web search, data collection, and chart plotting for a data-to-visualization pipeline.
  4. Projects needing a unified interface across multiple LLM providers.
  5. Developers wanting to leverage asynchronous execution for large-scale inference to maximize resource utilization.

How do you install or deploy this agent?

Install from source:\n``bash\ngit clone https://github.com/InternLM/lagent.git\ncd lagent\npip install -e .\n``

How do you use this agent?

After installation, you can create an LLM instance (e.g., VllmModel) and an Agent, then pass user messages to get responses. For example:\n``python\nfrom lagent.llms import VllmModel\nfrom lagent.agents import Agent\nfrom lagent.schema import AgentMessage\n\nllm = VllmModel(path='Qwen/Qwen2-7B-Instruct')\nagent = Agent(llm)\nuser_msg = AgentMessage(sender='user', content='What is the weather today?')\nbot_msg = agent(user_msg)\nprint(bot_msg)\n``\nFor tool use, define an ActionExecutor with hooks to execute code.

Safety boundaries, hardening & integrations

Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.

Declared capability surface (blast radius)

Local shell command execution

Can run terminal commands; pair with approval gates or container/OS sandboxing.

Local filesystem read/write

Modifies local files; work on a clean Git branch or dedicated worktree.

Outbound network access

Makes outbound requests; verify telemetry settings and model data routing on private repos.

FARS trust-control audit

Not found in source — apply before daily use
  • confirmation before acting — Turn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.

What are this agent's strengths and limitations?

Pros
  • PyTorch-like design philosophy makes it easy to understand and extend.
  • Supports multiple LLM backends (Vllm, GPTAPI) and tools (IPython, WebBrowser).
  • Provides synchronous and asynchronous interfaces for different scale requirements.
  • Flexible aggregators and parsers allow customization of message formats and tool usage.
Limitations
  • Requires users to have some Python and LLM knowledge.
  • Documentation may be limited; users may need to rely on examples.
  • Depends on external LLM APIs or local model serving, requiring API keys or hardware resources.
  • Async usage requires ensuring component consistency, adding configuration complexity.

How does this agent compare with similar options?

Similar to AutoGen and LangGraph, but Lagent is lighter and emphasizes a PyTorch-style design with more intuitive layer and message passing concepts.

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
Lagent Lightweight Agent Framework This agent 46 · Major gaps Library / SDKFree + model costs ★ 2.3k 7mo ago Python OpenAI API
ConnectOnion AI Agent Framework 62 · Some gaps CLIFree + model costs ★ 1.6k 1d ago Python OpenAI API · Claude API
Hello-Agents 53 · Major gaps Web appFree + model costs ★ 88k 20d ago Python OpenAI API
AgentVerse 43 · Major gaps CLIFree + model costs ★ 5.2k 2y ago JavaScript OpenAI API

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Major gaps
46/ 100 5-point scale 2.3 / 5
Trust 10/29
Reliability 6/14
Adaptability 9/18
Convention 10/18
Effectiveness 7/13
Verifiability 4/8
Why each dimension lost points
Trust10 / 29 · 1.7/5

The code shows messages being aggregated and sent to an LLM, then tools being invoked through ActionExecutor; the HTTP API also exposes session memory, making part of the data path visible (2). Examples use external API keys, a browser, and a code interpreter, but do not describe least-privilege configuration, sensitive-data protections, or confirmation before execution. Tool and external effects are configurable by callers, yet no consent gate, sandbox boundary, or rollback guidance is shown, so these criteria score 0–1. The project cites PyTorch as design inspiration and provides Apache-2.0 terms, but the sample does not establish detailed source attribution or maintenance ownership (1 for attribution).

Reliability6 / 14 · 2.1/5

The README advises keeping synchronous and asynchronous components consistent and using session_id for isolation, but visible differences between documentation and code, including the aggregator example interface, warrant checking examples against actual APIs; self-consistency scores 1. requirements.txt includes runtime and optional requirement files whose contents are not supplied, so dependency pinning and availability are unverified (1). The HTTP service logs internal exceptions while returning a generic 500, and search-action tests distinguish API and HTTP errors, supporting a score of 2 for failure messages.

Adaptability9 / 18 · 2.5/5

The README covers single-agent and multi-agent workflows, sync/async APIs, tools, memory, and message formatting, with research, writing, math, and plotting scenarios, giving developers useful starting points (2). Hooks, aggregators, parsers, and custom actions support extension, but the materials do not define unsupported use cases or safety boundaries; examples rely on specific tool formats and fixed loops without explaining constraints on model tool calls (1). Python, model-service, external-API, and session-concurrency assumptions are partly described, but no platform matrix or complete environment requirements are supplied (2).

Convention10 / 18 · 2.8/5

The README is organized around installation, core concepts, tools, interfaces, and practice; main API names such as Agent, AsyncAgent, and ActionExecutor are reasonably clear, and tutorials are substantial (2). Installation only gives a source checkout and editable install, without dependency or configuration detail. Limitations are mentioned only in scattered guidance, while a release history and maintenance responsibility are not established by the supplied material (1 each). The complete Apache License 2.0 text is present and matches the metadata (3).

Effectiveness7 / 13 · 2.7/5

Examples show AgentMessage, memory, parsers, and executor results in forms that can be consumed by code; async APIs, session memory, and composable actions provide practical development value (2 each). Cost-benefit claims are general, such as using idle CPU/GPU capacity for async inference, without evidence about resource costs, deployment scale, or tradeoffs (1).

Verifiability4 / 8 · 2.5/5

The README's main feature claims have implementation pointers in the tutorial and agent.py/API sample (2). Supplied tests cover basic actions, search error branches, and interpreter timeout, but only partly corroborate the complete Agent workflows shown in the README (1). Documentation mixes design intent, advice, and examples; the materials do not independently establish some demonstrated outputs or clearly separate facts from inference (1).

Risks and how to mitigate them
  • Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
  • The examples include Python/IPython interpreters, a browser, and an HTTP service that may execute code, contact external services, or expose session memory. The supplied material does not show sandboxing, authentication, access controls, or user confirmation; verify these boundaries before deployment.
  • The contents of the requirement files referenced by requirements.txt are not supplied, and model/API examples depend on external services. This review did not execute code or verify dependencies, example outputs, or current maintenance status.
Evidence confidence: Low Reviewed Nov 08, 2026 Reviewed revision 0ab2e2f55047
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/lagent.svg)](https://followagents.com/en/agents/lagent)
<a href="https://followagents.com/en/agents/lagent"><img src="https://followagents.com/badge/lagent.svg" alt="FARS review"></a>

Recent releases

Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.

  1. agentrl_rc0
  2. v0.5.0rc3
    Release notes excerpt
    What's Changed * Update runtime.txt add tenacity by @vansin in https://github.com/InternLM/lagent/pull/280 * Fixed the search API of AsyncDDGS by @braisedpork1964 in https://github.com/InternLM/lagent/pull/281 * [Model] support Claude by @Harold-lkk in https://github.com/InternLM/lagent/pull/283 * fix anthropic by @Harold-lkk in https://github.com/InternLM/lagent/pull/284 * support o1 and claude by @Harold-lkk in https://github.com/InternLM/lagent/pull/285 * Add do_sample in AsyncLMDeployPipeline (lmdeploy_wrapper.py) by @shinkungoo in https://github.com/InternLM/lagent/pull/290 …
    View on GitHub ↗
  3. v0.5.0rc2 V0.5.0rc2
    Release notes excerpt
    What's Changed * Update dependencies by @braisedpork1964 in https://github.com/InternLM/lagent/pull/268 * [Feat] Add Sequential and AsyncSequential agents by @braisedpork1964 in https://github.com/InternLM/lagent/pull/270 * [Fix] Alternative for aioify by @braisedpork1964 in https://github.com/InternLM/lagent/pull/274 * [Feat] Support resetting agent memory recursively or by keypath by @braisedpork1964 in https://github.com/InternLM/lagent/pull/271 * Fix: http agent server by @liujiangning30 in https://github.com/InternLM/lagent/pull/276 …
    View on GitHub ↗

FAQ

Does Lagent support local models?
Yes, Lagent supports local models via VllmModel, such as Qwen/Qwen2-7B-Instruct.
Can I customize tool calling?
Yes, you can implement custom tool calling by writing hooks and custom aggregators.
Does Lagent support multi-agent collaboration?
Yes, you can create multiple Agents and coordinate them via message passing, as shown in the blogging example.
What hardware is required to deploy Lagent?
It depends on the LLM backend. For local models, sufficient GPU memory is needed; for APIs, no local GPU is required.
Was this page helpful?
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related concepts