agentlite
A small, focused library for building Claude-powered agents in Python. Minimal abstractions, prompt caching done right, permissions as a first-class concept.
What does this project do?
agentlite is a tiny (~2,000 lines) Python library that turns plain Python functions into tools an LLM can call, then runs the full agent loop for you — sending the request to Claude, executing the tools Claude asks for, feeding the results back, and stopping when Claude is done. It bakes in three things most lightweight agent libraries skip: prompt caching is on by default (~80% input cost reduction on repeated requests), permission gating is first-class (mark a tool as requires_confirmation=True and the user is asked before it runs), and a max_turns safety brake prevents runaway loops. You write the tools, you write the system prompt, the library handles the orchestration — no chains, no graphs, no 150K lines of framework to debug.
from agentlite import Agent, tool
@tool
def get_weather(city: str) -> str:
"""Return current weather for a city."""
return f"{city}: 22°C, sunny"
agent = Agent(model="claude-opus-4-7", tools=[get_weather])
agent.run("What's the weather in Istanbul?")
Why agentlite?
If you've ever tried to build a Claude agent in Python you've probably faced this choice:
- Anthropic SDK directly → fast but you write the agent loop, retry logic, permission handling, and prompt caching yourself.
- LangChain → batteries included but ~150K lines of abstractions to navigate, and debugging often means reading the framework's source.
agentlite sits in between: ~2,000 lines of focused code that handles the agent loop, tool definitions, prompt caching, and permissions — and gets out of your way for everything else.
Status
🚧 Alpha (v0.1.0) — under active development. API may change before v1.0.
Installation
pip install agentlite-py
The PyPI distribution name is
agentlite-py(the bareagentliteis taken by an unrelated package). The Python import is stillagentlite:from agentlite import Agent, tool.
Requires Python 3.10+. Get an Anthropic API key from console.anthropic.com.
Quick start
export ANTHROPIC_API_KEY="sk-ant-..."
from agentlite import Agent, tool
@tool
def search_files(pattern: str) -> list[str]:
"""Find files matching a glob pattern."""
from glob import glob
return glob(pattern)
@tool
def read_file(path: str) -> str:
"""Read a text file's contents."""
return open(path, encoding="utf-8").read()
agent = Agent(
model="claude-opus-4-7",
system="You help users explore their codebase.",
tools=[search_files, read_file],
)
agent.run("Find all Python files and summarize the largest one.")
Features
@tooldecorator — type hints become JSON Schema, docstring becomes description.- Built-in agent loop with
max_turnssafety brake. - Streaming support —
agent.stream_text()for token-by-token output. - Prompt caching by default — system prompt + tools cached automatically; typically ~80% input cost reduction on repeated requests.
- Verifiable caching — inspect
response.usage.cache_read_input_tokensto confirm hits (no silent failures). - Permission system (planned) — mark tools as
requires_confirmationorread_only. - Sub-agent support (planned) — delegate sub-tasks without polluting context.
Comparison
| LangChain | OpenAI Agents | Anthropic SDK (raw) | agentlite | |
|---|---|---|---|---|
| LoC to read | ~150K | ~5K | — | ~2K |
| Prompt caching | manual | none | manual | automatic |
| Permission model | none | none | none | first-class |
| Multi-agent | complex | handoffs | none | @subagent |
| Learning curve | steep | medium | low | very low |
Documentation
Full docs and design notes at: https://hakansabunis.com
License
MIT © 2026 Hakan Sabunis
Metadata
Release files for agentlite-py 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| agentlite_py-0.2.0.tar.gz | 39.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentlite_py-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 63.3 kB
Release files / agentlite_py-0.2.0.tar.gz
| Download URL | agentlite_py-0.2.0.tar.gz |
|---|---|
| Size | 39.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b03d551ee591bbc4a9c3e03a1c03d4400d02bcddce0aa7a03f62c6cd8f943e1
|
|
BLAKE2b-256 checksum How to use checksums |
dd8cf5db1d0400bfad5776b0bd27f07fec237803dd350ceb5eb81177e7a3ca59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / agentlite_py-0.2.0-py3-none-any.whl
| Download URL | agentlite_py-0.2.0-py3-none-any.whl |
|---|---|
| Size | 23.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ae5392a775110b71db48b5cf54ae3d5e02ef9a7d49b3346dbd3093b5bc9971f
|
|
BLAKE2b-256 checksum How to use checksums |
3a35c858c52f6705c881b74b8da450ab845881261ed467200cb41e7dfb412dad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for agentlite-py 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.