Skip to main content

pureagents

PyPI Python License

The simplest agent framework. And the most capable.

Documentation · Quick start · API


A Python library for building LLM agents. One file you can read in 30 minutes. Tools, streaming, memory, structured outputs, multi-agent orchestration. No magic, no abstractions you don't need.


Installation

pip install pureagents

Usage

from pure_agents import Agent, tool

@tool
def search(query: str) -> str:
    """Search the web."""
    return f"Results for {query}..."

agent = Agent(tools=[search])
result = await agent.run("Find the weather in Madrid")

Features

Feature Usage
Tools @tool decorator, type hints become JSON schemas
Providers provider="openai" (Mistral, OpenAI, Anthropic)
Streaming agent.stream()
Memory session="my-chat"
Structured outputs output=MyDataclass
Hooks on_tool_call=fn
Batch agent.batch([...])
Chaining chain([agent1, agent2], prompt)
Routing Router(agents={...}, route=fn)
Planning agent.run(prompt, plan=True)
Graph Graph() with nodes and conditional edges
Retry retries=3
Timeout timeout=30.0
Context limit max_messages=20
Usage tracking agent.usage

All features are optional. One parameter enables one feature.

Providers

# Mistral (default)
agent = Agent(provider="mistral", model="mistral-large-latest")

# OpenAI
agent = Agent(provider="openai", model="gpt-4o")

# Anthropic
agent = Agent(provider="anthropic", model="claude-sonnet-4-20250514")

API keys via environment variables (MISTRAL_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY) or api_key=.

Streaming

async for event in agent.stream("Write a poem"):
    if event.type == "text":
        print(event.content, end="", flush=True)
    elif event.type == "tool_call":
        print(f"\nCalling {event.name}...")

Memory

agent = Agent(session="my-chat")
await agent.run("I'm Jose")
# Later...
await agent.run("What's my name?")  # Remembers

# Manual
agent.save("conversation.json")
agent.load("conversation.json")

Structured outputs

from dataclasses import dataclass

@dataclass
class Analysis:
    sentiment: str
    confidence: float
    keywords: list[str]

result = await agent.run(
    "Analyse this review: 'Great product!'",
    output=Analysis
)

Why

We follow Anthropic's philosophy: start simple, add complexity only when needed. Most agent frameworks do the opposite.

This library gives you a clean starting point that breaks the blank page problem. Instead of figuring out how to structure your agent code, you get a working foundation with sensible defaults. Then you adapt it to your needs.

  • ~1,500 lines total. Read the entire codebase in one sitting.
  • No hidden behaviour. What you see is what runs.
  • Modular by default. Each feature is independent. Use what you need.
  • Built to be forked. If it doesn't fit your use case, copy and modify it.

Ideal for

  • Projects that need full control. No black boxes.
  • Teams that want to understand their code. Not just use it.
  • Prototypes that might become products. Start simple, grow as needed.
  • Learning how agents work. The code is the documentation.

Contributing

See CONTRIBUTING.md.

Licence

Apache 2.0

Metadata

Release files for pureagents 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 pureagents 0.1.0
File Size Uploaded
pureagents-0.1.0.tar.gz 208.3 kB Details

Built distribution (wheel)

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

Total release size: 228.4 kB

Release files / pureagents-0.1.0.tar.gz

Download URL pureagents-0.1.0.tar.gz
Size 208.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ca58f9be8206f697fb7b0e0a55544c25425887da4183b6b2f1e56acb40601e19
BLAKE2b-256 checksum
How to use checksums
910b9df20c81a6dfd993bb362749026fb0f0d1a015c21a1dae3dc80624ac56e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.6

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

Download URL pureagents-0.1.0-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8384ebf646df77e959da0a9dcae8863ecc380b5c8d08258d4bf35a8366969c0c
BLAKE2b-256 checksum
How to use checksums
8201f15c7997a1364dc021c53f4a9618890bf234f099bb7fa46c3fdb5b2e22e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.6

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