← all repositories
mpaepper/llm_agents

A Bare-Bones Rebuild of LangChain’s Agent Loop

Built to demystify LLM agents by recreating LangChain’s core reasoning loop in as few lines of code as possible.

1.1k stars Python AgentsLanguage Models
llm_agents
Not currently ranked — collecting fresh signals.
star history

What it does

It is a small Python library that constructs autonomous agents driven by large language models. The agent follows a tight cycle: the LLM generates a thought and selects an action, a tool executes that action and returns an observation, and the appended result is fed back into the prompt for the next reasoning step. The process repeats until the model decides it has enough context to answer. Built-in tools include a Python REPL, a Google search interface via SerpAPI, and a Hacker News search.

The interesting bit

The value is precisely in its lack of features: the author deliberately discarded LangChain’s sprawling abstractions to expose the bare prompt-engineering mechanics that make agent loops work. It treats the agent not as magic but as a while-loop that appends strings to a prompt until the LLM stops calling tools. If you have ever wondered what LangChain is actually doing under the hood, this is the annotated skeleton.

Key highlights

  • Re-implements the classic Thought → Action → Observation loop with minimal indirection
  • Ships with three ready-made tools: PythonREPLTool, SerpAPITool, and HackerNewsSearchTool
  • Designed for readability and hacking; the entire logic fits in a small surface area
  • Lets you compose custom tools or drop the ones you do not need
  • Requires an OpenAI API key and optionally a SerpAPI key for search

Caveats

  • Currently locked to the OpenAI API; the README mentions no other LLM backends.
  • Google search requires a separate SerpAPI key, and the out-of-the-box tool set covers only Python execution, web search, and Hacker News search.
  • The author explicitly positions it as a learning exercise rather than a maintained alternative to LangChain.

Verdict

Good for developers who want to understand the prompt mechanics behind agent loops without navigating a larger framework. Skip it if you are looking for a production-ready orchestration layer or broad model support.

Frequently asked

What is mpaepper/llm_agents?
Built to demystify LLM agents by recreating LangChain’s core reasoning loop in as few lines of code as possible.
Is llm_agents open source?
Yes — mpaepper/llm_agents is open source, released under the MIT license.
What language is llm_agents written in?
mpaepper/llm_agents is primarily written in Python.
How popular is llm_agents?
mpaepper/llm_agents has 1.1k stars on GitHub.
Where can I find llm_agents?
mpaepper/llm_agents is on GitHub at https://github.com/mpaepper/llm_agents.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.