Skip to main content

⚡ LightAgentX

A lightweight, modular agentic AI framework built from scratch.
No LangChain. No CrewAI. No magic. Just clean Python.

PyPI Python License


What is LightAgentX?

LightAgentX is a ~1,200 line Python framework that rebuilds every core pattern from LangChain and CrewAI from first principles — LLM abstraction, memory, tools, planning, the agent loop, and multi-agent orchestration.

Every module is transparent, composable, and designed to teach you exactly what happens when an AI agent "thinks", "remembers", or "uses a tool".

lightagentx/
├── llm/          LLM abstraction (swap providers without changing agent code)
├── memory/       Conversation memory (buffer + LLM-compressed summary)
├── tools/        Tool system (@tool decorator → JSON Schema → execution)
├── planning/     ReAct reasoning (Thought → Action → Observation)
├── loop/         Core agent loop (the heart of ALL agentic frameworks)
├── agents/       Single agents, sequential pipelines, crew orchestration
└── utils/        Colored logger for tracing

Installation

pip install lightagentx

Or install from source:

git clone https://github.com/devansh/lightagentx.git
cd lightagentx
pip install -e .

Quick Start

from lightagentx import OpenAILLM, SingleAgent, tool

# 1. Create an LLM
llm = OpenAILLM()  # uses OPENAI_API_KEY env var

# 2. Define tools
@tool
def calculate(expression: str) -> str:
    """Evaluate a math expression.

    Args:
        expression: A math expression like '2 + 3 * 4'.
    """
    return str(eval(expression))

# 3. Create an agent
agent = SingleAgent(name="MathBot", llm=llm, tools=[calculate])

# 4. Run it
print(agent.run("What is 25 * 37?"))
# → "25 × 37 = 925"

📖 Full usage guide → docs/guide.md


Features

Feature Description
🔌 Pluggable LLMs Swap between OpenAI, Anthropic, or any provider via BaseLLM
🧠 Memory BufferMemory (sliding window) and SummaryMemory (LLM-compressed)
🔧 Tools @tool decorator auto-generates JSON Schema from type hints
🧪 ReAct Planning Thought → Action → Observation reasoning loop
⚙️ Agent Loop The universal LLM → decide → execute → observe loop
👥 Multi-Agent Sequential pipelines and hierarchical crew delegation
🎨 Colored Logger Visual trace of every agent decision

Examples

# Basic chat with memory
python examples/01_basic_chat.py

# Agent with tools (calculator, weather, time)
python examples/02_tool_agent.py

# ReAct reasoning loop
python examples/03_react_agent.py

# Multi-agent pipelines + crew
python examples/04_multi_agent.py

Testing

All tests use mocked LLM responses — no API key required:

pip install -e ".[dev]"
python -m pytest tests/ -v
72 passed in 0.96s ✅

How It Maps to LangChain & CrewAI

LightAgentX LangChain CrewAI
BaseLLM / OpenAILLM BaseChatModel / ChatOpenAI —
BufferMemory ConversationBufferWindowMemory —
SummaryMemory ConversationSummaryMemory —
@tool / BaseTool @tool / StructuredTool @tool
ToolRegistry format_tool_to_openai_function() —
AgentLoop AgentExecutor.invoke() Agent loop
SingleAgent create_tool_calling_agent + AgentExecutor Agent
SequentialPipeline SequentialChain / LCEL pipes Crew(process=sequential)
CrewAgent — Crew(process=hierarchical)

Architecture

Dependency flow (each layer only knows about layers below it):

  logger → llm → memory → tools → planning → loop/engine → agents

Design patterns used:

  • Strategy — BaseLLM, BaseMemory, BasePlanner (swappable implementations)
  • Decorator — @tool converts functions into tool objects
  • Composite — Pipelines and crews are agents themselves (nestable)

License

MIT — see LICENSE.

Metadata

Release files for lightagentx 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lightagentx 0.1.0
File Size Uploaded
lightagentx-0.1.0.tar.gz 33.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lightagentx 0.1.0
File Interpreter ABI Platform
lightagentx-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 66.3 kB

Release files / lightagentx-0.1.0.tar.gz

Download URL lightagentx-0.1.0.tar.gz
Size 33.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e74766e31f35bbef11f0bce8e00ccc5a5efb83af429c502404ba917e18f46f11
BLAKE2b-256 checksum
How to use checksums
01632916b5663262588c5cf2a04d1f9b92c1525670790e67589afd50592fdf36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

Release files / lightagentx-0.1.0-py3-none-any.whl

Download URL lightagentx-0.1.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd9d02648f5697fbc46c331ca99639980d6401f0e3823d2dfa9036940bb04ff5
BLAKE2b-256 checksum
How to use checksums
415355df3e601e6c87c3168d9a68f169b8216183348c726ef17e8b8a2775554f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page