Skip to main content

A small, focused library for building Claude-powered agents in Python.

Project description

agentlite

tests Python License

A small, focused library for building Claude-powered agents in Python. Minimal abstractions, prompt caching done right, permissions as a first-class concept.

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 bare agentlite is taken by an unrelated package). The Python import is still agentlite: 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

  • @tool decorator — type hints become JSON Schema, docstring becomes description.
  • Built-in agent loop with max_turns safety brake.
  • Streaming supportagent.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_tokens to confirm hits (no silent failures).
  • Permission system (planned) — mark tools as requires_confirmation or read_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentlite_py-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentlite_py-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file agentlite_py-0.1.0.tar.gz.

File metadata

  • Download URL: agentlite_py-0.1.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for agentlite_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7906d97d87a225bf09fc336112e0cdf394dfd2d1925890242ab4d1630073ddb5
MD5 24e63c45ecc245b061dbb9c1f7d45fe0
BLAKE2b-256 1575215c374ee09157f395b04d11c1945b5c659276b38a27ffc5a1861bbc51e6

See more details on using hashes here.

File details

Details for the file agentlite_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agentlite_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for agentlite_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c4ddbd89c88a46f49843e1bcf88ade90e8517dd8dda3b844353af921b415361
MD5 541e17f03315e84f3b7ef5d89d57f5bd
BLAKE2b-256 e5d41e2ccf22b8f6c767823ec17e0b54dbc19e52f767ae912b74b7a8987a110d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page