Async-first Python agent framework with tools, skills, MCP, sessions, and tracing.
Project description
Hajimi Agent
Hajimi is a small async-first Python agent framework built around
any-llm-sdk direct async APIs.
Core capabilities:
- TOML and
.envbased configuration. - Loguru console and rotating file logging.
- Async completion, streaming completion, embedding, and Responses API wrappers.
- A typed core with message parts, stream events, context objects, and a compact agent loop with optional tool dispatch.
- Workspace read/search tools, opt-in write/shell tools, local skills with progressive activation, optional MCP tools, BM25 tool search, agent-as-tool subagents, and persistent in-process teammates.
- Durable
AgentSessioncontext with JSONL events, SQLAlchemy ORM indexes defaulting to SQLite, forks, edit/delete/restore markers, compaction, and token reports with optional provider cache usage. - JSONL tracing with optional OpenTelemetry export.
- Pytest coverage for configuration, logging, LLM wrappers, tools, skills, MCP, sessions, tracing, subagents, teammates, workspace tools, and dynamic tool search.
Quick start:
uv sync
cp examples/configs/.env.example examples/configs/.env
export HAJIMI_API_KEY=...
export HAJIMI_BASE_URL=https://api.deepseek.com
export HAJIMI_MODEL=deepseek-chat
uv run hajimi chat "hi"
uv run python examples/basic_agent.py
uv run pytest -q
CLI:
hajimi chat "hi"
hajimi chat --json "hi"
hajimi agent models --json
hajimi tool list
hajimi mcp list
hajimi skill list
Examples:
uv run python examples/basic_agent.py
uv run python examples/stream.py
uv run python examples/tools.py
uv run python examples/custom_loop.py
uv run python examples/session.py
uv run python examples/routed_runtime.py
uv sync --extra mcp
uv run python examples/mcp_stdio.py
Minimal one-call usage (no TOML required):
# Export at least one provider key, e.g.:
# export HAJIMI_API_KEY=... # overrides the selected configured model
# export HAJIMI_BASE_URL=... # optional provider endpoint
# export HAJIMI_MODEL=deepseek-chat # optional model id override
# export OPENAI_API_KEY=... # auto-detected as the openai default
# export DEEPSEEK_API_KEY=... # auto-detected as the deepseek default
# export HAJIMI_DEFAULT_MODEL=openai # optional, when several keys are set
from hajimi import Hajimi
print(await Hajimi.ask("hello"))
Typed core API:
from hajimi import TextDelta, user_message
async with agent.run_stream([user_message("hello")]) as run:
async for event in run:
if isinstance(event, TextDelta):
print(event.chunk, end="")
print(run.output)
Custom loop API:
from collections.abc import AsyncIterator
import hajimi as ai
class CustomAgent(ai.Agent):
async def loop(self, context: ai.Context) -> AsyncIterator[ai.AgentEvent]:
while context.keep_running():
async with (
ai.stream(context=context) as stream,
ai.ToolRunner() as tools,
):
async for event in ai.merge(stream, tools.events()):
yield event
if isinstance(event, ai.ToolEnd):
tools.schedule(context.resolve(event.tool_call))
context.add(stream.message)
context.add(tools.get_tool_message())
Power-user knobs travel on a single RunOptions object:
from hajimi import AgentRuntime, RunOptions, load_config
runtime = await AgentRuntime.from_config(await load_config())
result = await runtime.run_task(
"draft a release note for v0.2",
options=RunOptions(
mode="auto",
max_cost_usd=0.05,
max_total_tokens=8000,
on_budget_exceeded="stop",
),
)
print(result.content, result.cost)
Optional extras:
uv sync --extra mcp
uv sync --extra observability
Docs:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hajimi-0.1.1.tar.gz.
File metadata
- Download URL: hajimi-0.1.1.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fdac55c504809913c6afb71df88e52fe90a6c332eaad57ece50c1cd9afb298c
|
|
| MD5 |
23273055625f0e384d82b8755a6521e6
|
|
| BLAKE2b-256 |
45f320f04d9347a1eafa7ef06d0c5596e6f114e695951b77a5dc0f74c4e36f9f
|
File details
Details for the file hajimi-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hajimi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 177.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76d9bb4ec712bdaf21897f1d0aaf303b5350dc6a3bb30ff6c64015406e4f69ff
|
|
| MD5 |
2455a695d977f1ce86525032af2839a5
|
|
| BLAKE2b-256 |
7d754d04eb6e3ccc6274932f44b4400c82109cb97bccd4180101c22e81a616e2
|