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 corekit 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
uv run python examples/basic_agent.py
uv run pytest -q
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 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.0.tar.gz.
File metadata
- Download URL: hajimi-0.1.0.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 |
6f860416554bc57f7cf000529d2b7c45856bcab87d2e3d79ad87d7033d41c5b5
|
|
| MD5 |
ade1b04f05a86a31bc64d1397321d7a4
|
|
| BLAKE2b-256 |
6a8f1eac65bdd620b023985b2734a5bc85c2782f96dc7b61148ac293fbc7abe0
|
File details
Details for the file hajimi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hajimi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 170.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a3626f95f02fac6890d07b8dec14e705d6581d70a4ff473d046be2305bd9fd1
|
|
| MD5 |
05fd849224734eb5348a8c2e9cab6db9
|
|
| BLAKE2b-256 |
af83c0da9131a466abb3a2812a5ea55458bb43ee16a0115fe7c7de1c3dabd142
|