A minimal, dependency-free tool-calling agent loop — the entire mechanism
(call model → check for tool call → run tool → feed result back → repeat)
fits in about 80 lines, in agentkit/agent.py.
Most agent frameworks bury this loop under thousands of lines of abstraction. This one doesn't hide it, because the loop is the interesting part — everything else is just plumbing to make it swappable.
Not a "build production agents with 10x less code" pitch. It's a small, readable reference for anyone who wants to see exactly how a tool-calling agent loop works, or who wants a 3-file starting point instead of a 2000-star framework with an opinion about everything.
git clone https://github.com/slymp3/agentkit-lite
cd agentkit-lite
python examples/demo_mock.pyThis runs the real agent loop against a scripted fake model
(MockClient), so you can see the tool-call → tool-result → answer cycle
without any setup. Output:
[tool] calculator({'expression': '12 * (7 + 1)'})
final answer: 12 * (7 + 1) = 96.
pip install anthropic
export ANTHROPIC_API_KEY=sk-...
python examples/demo_live.pyfrom agentkit.tools import registry
@registry.register(
name="get_weather",
description="Get current weather for a city.",
schema={"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
)
def get_weather(city: str) -> str:
...
return f"{city}: 72F, clear"That's the whole interface. One decorator, one function, one JSON schema.
| File | Purpose |
|---|---|
agentkit/agent.py |
The loop itself (Agent, ModelResponse, ToolRegistry) |
agentkit/tools.py |
Three example tools: calculator, file reader, word counter |
agentkit/clients.py |
MockClient (offline) and AnthropicClient (real API) |
examples/demo_mock.py |
Runs with zero setup |
examples/demo_live.py |
Runs against the real Claude API |
No retries, no streaming, no async, no multi-agent orchestration, no memory store. Those are all real problems worth solving — they're just not what this repo is for. Fork it if you need them.
MIT