{"id":50398811,"url":"https://github.com/hakansabunis/agentlite","last_synced_at":"2026-05-30T22:02:08.939Z","repository":{"id":359077758,"uuid":"1244422901","full_name":"hakansabunis/agentlite","owner":"hakansabunis","description":"A small, focused library for building Claude-powered agents in Python — minimal abstractions, prompt caching, permissions as first-class.","archived":false,"fork":false,"pushed_at":"2026-05-20T10:48:17.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-20T12:43:10.340Z","etag":null,"topics":["agent","ai","anthropic","claude","llm","prompt-caching","python","tool-use"],"latest_commit_sha":null,"homepage":"https://hakansabunis.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hakansabunis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-20T08:50:41.000Z","updated_at":"2026-05-20T10:48:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hakansabunis/agentlite","commit_stats":null,"previous_names":["hakansabunis/agentlite"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hakansabunis/agentlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakansabunis%2Fagentlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakansabunis%2Fagentlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakansabunis%2Fagentlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakansabunis%2Fagentlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hakansabunis","download_url":"https://codeload.github.com/hakansabunis/agentlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakansabunis%2Fagentlite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33711018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","anthropic","claude","llm","prompt-caching","python","tool-use"],"created_at":"2026-05-30T22:02:07.658Z","updated_at":"2026-05-30T22:02:08.922Z","avatar_url":"https://github.com/hakansabunis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# agentlite\n\n[![PyPI](https://img.shields.io/pypi/v/agentlite-py.svg)](https://pypi.org/project/agentlite-py/)\n[![tests](https://github.com/hakansabunis/agentlite/workflows/tests/badge.svg)](https://github.com/hakansabunis/agentlite/actions)\n[![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org)\n[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)\n\n\u003e A small, focused library for building Claude-powered agents in Python.\n\u003e Minimal abstractions, prompt caching done right, permissions as a first-class concept.\n\n## What does this project do?\n\n**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.\n\n```python\nfrom agentlite import Agent, tool\n\n@tool\ndef get_weather(city: str) -\u003e str:\n    \"\"\"Return current weather for a city.\"\"\"\n    return f\"{city}: 22°C, sunny\"\n\nagent = Agent(model=\"claude-opus-4-7\", tools=[get_weather])\nagent.run(\"What's the weather in Istanbul?\")\n```\n\n## Why agentlite?\n\nIf you've ever tried to build a Claude agent in Python you've probably faced this choice:\n\n- **Anthropic SDK directly** → fast but you write the agent loop, retry logic, permission handling, and prompt caching yourself.\n- **LangChain** → batteries included but ~150K lines of abstractions to navigate, and debugging often means reading the framework's source.\n\n**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.\n\n## Status\n\n🚧 **Alpha** (v0.2.0) — under active development. API may change before v1.0.\nSee [CHANGELOG.md](CHANGELOG.md) for the full release history.\n\n## Installation\n\n```bash\npip install agentlite-py\n```\n\n\u003e The PyPI distribution name is **`agentlite-py`** (the bare `agentlite` is taken by an unrelated package).\n\u003e The Python import is still `agentlite`: `from agentlite import Agent, tool`.\n\nRequires Python 3.10+. Get an Anthropic API key from [console.anthropic.com](https://console.anthropic.com).\n\n## Quick start\n\n```bash\nexport ANTHROPIC_API_KEY=\"sk-ant-...\"\n```\n\n```python\nfrom agentlite import Agent, tool\n\n@tool\ndef search_files(pattern: str) -\u003e list[str]:\n    \"\"\"Find files matching a glob pattern.\"\"\"\n    from glob import glob\n    return glob(pattern)\n\n@tool\ndef read_file(path: str) -\u003e str:\n    \"\"\"Read a text file's contents.\"\"\"\n    return open(path, encoding=\"utf-8\").read()\n\nagent = Agent(\n    model=\"claude-opus-4-7\",\n    system=\"You help users explore their codebase.\",\n    tools=[search_files, read_file],\n)\n\nagent.run(\"Find all Python files and summarize the largest one.\")\n```\n\n## Features (v0.2.0)\n\n- **`@tool` decorator** — type hints become JSON Schema, docstring becomes description.\n- **Built-in agent loop** with `max_turns` safety brake.\n- **`agent.stream()`** — full streaming with tool-loop integration. Yields\n  `TextDeltaEvent`, `ToolUseEvent`, `ToolResultEvent`, `DoneEvent` so you can\n  render live token output AND react to tool calls.\n- **Prompt caching by default** — system prompt + tools cached automatically.\n- **`subagent(...)` factory** — delegate sub-tasks to isolated agents without\n  polluting parent context. Sub-agents are exposed as tools.\n- **Permission system** — `@tool(requires_confirmation=True)` with pluggable\n  `confirm_fn` (terminal default, override for GUI/Slack/web).\n- **`tool_choice` control** — `\"auto\"` / `\"any\"` / `\"none\"` / specific tool name.\n- **Typed exceptions** — `AgentError` base + 5 subclasses, structured fields\n  (`.max_turns`, `.tool_name`, `.original`, `.stop_reason`).\n- **`Usage` tracking** — accumulated tokens after each run via `agent.last_usage`,\n  with `.estimate_cost_usd(model)` for built-in pricing.\n- **`agentlite.testing`** — `MockClient` + factories for testing your agent\n  code without hitting the real API.\n\n## Comparison\n\n| | LangChain | OpenAI Agents | Anthropic SDK (raw) | **agentlite** |\n|---|---|---|---|---|\n| LoC to read | ~150K | ~5K | — | **~2K** |\n| Prompt caching | manual | none | manual | **automatic** |\n| Permission model | none | none | none | **first-class** |\n| Multi-agent | complex | handoffs | none | **`@subagent`** |\n| Learning curve | steep | medium | low | **very low** |\n\n## Documentation\n\nFull docs and design notes at: **https://hakansabunis.com**\n\n## License\n\nMIT © 2026 Hakan Sabunis\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakansabunis%2Fagentlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhakansabunis%2Fagentlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakansabunis%2Fagentlite/lists"}