Skip to main content

A tiny Python agent runtime with tools, middleware, and events.

Project description

MiniADK

简体中文

MiniADK is a small Python Agent Development Kit for building tool-using agents with a compact, readable API.

It gives you the pieces needed to build agent products:

  • Agent for instructions and capabilities
  • Model adapters for LLM providers
  • Tool wrappers for Python functions
  • Runtime for the agent loop
  • Event streams for adapters and UIs
  • Session helpers for conversation state

MiniADK is a development kit, not a finished agent product. The core stays small, while providers, tools, policies, skills, MCP, CLI adapters, and presets live around it.

Install

Clone the source and install it in editable mode:

git clone https://github.com/Saglear/miniadk.git
cd miniadk
uv sync --extra dev

Run the test suite:

uv run --extra dev pytest -q

Quick Start

from miniadk import Agent, model, run_cli, tool


@tool
def add(left: int, right: int) -> int:
    """Add two numbers."""
    return left + right


agent = Agent(
    "calc",
    "Use tools when they help.",
    tools=[add],
)

run_cli(agent, model=model())

Run it:

uv run python calc.py

One-Shot Calls

from miniadk import Agent, model, run, tool


@tool
def greet(name: str) -> str:
    """Return a greeting."""
    return f"hello {name}"


agent = Agent("hello", "Use tools when useful.", tools=[greet])
answer = run(agent, "Greet Ada", model=model())
print(answer)

Models

model() reads provider settings from environment variables and returns a configured adapter.

OpenAI-compatible settings:

OPENAI_KEY=...
OPENAI_URL=...
OPENAI_BASE_URL=...
OPENAI_MODEL=...

Anthropic settings:

ANTHROPIC_KEY=...
ANTHROPIC_URL=...
ANTHROPIC_BASE_URL=...
ANTHROPIC_MODEL=...

When more than one provider is configured, choose the default explicitly:

MINIADK_MODEL_PROVIDER=openai

or:

MINIADK_MODEL_PROVIDER=anthropic

Tools

Any typed Python function can become a tool:

from pathlib import Path

from miniadk import tool


@tool
def read_note(path: str) -> str:
    """Read a UTF-8 note."""
    return Path(path).read_text(encoding="utf-8")

MiniADK uses the function name, docstring, and type hints to build the tool schema. Sync and async functions are both supported.

Prebuilt Tools

Reusable tools are available from miniadk.stdtools:

from pathlib import Path

from miniadk import Agent, model, run_cli
from miniadk.stdtools import make_list_files, make_read_file, make_search_text

root = Path.cwd()
agent = Agent(
    "repo",
    "Help inspect this repository.",
    tools=[
        make_list_files(root=root),
        make_read_file(root=root),
        make_search_text(root=root),
    ],
)

run_cli(agent, model=model())

File and shell tools keep path checks, permission prompts, limits, and timeouts outside the atomic runtime.

Skills And MCP

Skills and MCP servers are business-layer integrations. They resolve into ordinary instructions and tools before the runtime loop runs.

from miniadk import Agent, MCPHub, MCPServer, SkillRegistry, model, run_cli

agent = Agent(
    "assistant",
    "Use the configured project capabilities.",
    skills=SkillRegistry.from_paths(".miniadk/skills"),
    mcp=MCPHub([
        MCPServer(name="docs", command="uvx", args=["some-mcp-server"]),
    ]),
)

run_cli(agent, model=model())

Core Shape

The runtime loop is intentionally direct:

user message
  -> model call
  -> optional tool calls
  -> tool results
  -> model response
  -> events

The core concepts are:

Message  - what the agent sees
Model    - how the agent asks an LLM what to do next
Tool     - what the agent can do
Agent    - instructions plus capabilities
Runtime  - the loop that connects everything
Event    - what adapters and UIs observe
Session  - persisted conversation state

Package Layout

src/miniadk/core/       atomic runtime types and loop
src/miniadk/models/     provider adapters
src/miniadk/stdtools/   reusable file, shell, web, and agent tools
src/miniadk/adapters/   CLI, JSON, web, and WebSocket adapters
src/miniadk/skills.py   skill loading and invocation helpers
src/miniadk/mcp.py      MCP integration
src/miniadk/presets.py  optional high-level assembly helpers

Import the common user-facing API from miniadk. Use submodules when you need advanced control.

Examples

uv run --extra dev python examples/smoke_llm.py
uv run --extra dev python examples/scripted_tiny_product.py
uv run --extra dev python examples/coder_preset.py
uv run --extra dev python examples/compact_coder.py
uv run --extra dev python examples/repo_cli.py
uv run --extra dev python examples/cli_interaction_lab.py

Development

uv sync --extra dev
uv run --extra dev pytest -q
uv build

License

MIT

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

miniadk-0.1.0.tar.gz (138.4 kB view details)

Uploaded Source

Built Distribution

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

miniadk-0.1.0-py3-none-any.whl (82.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: miniadk-0.1.0.tar.gz
  • Upload date:
  • Size: 138.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for miniadk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3a513829813960ce5a934291d90727c201c391443c5ee25f8154f3e08105874f
MD5 cb03729cad3b440479cd024f7930d317
BLAKE2b-256 b935461fbe13fb780cd28be4046d17b44007198de867f1e510e175e63429eb1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for miniadk-0.1.0.tar.gz:

Publisher: workflow.yml on Saglear/miniadk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: miniadk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 82.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for miniadk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59e388979a58261a49f90d007363867ba2e88f524136584d81cee53d2b4a9846
MD5 0dcd613684b25d537700bb1b27fca4ab
BLAKE2b-256 f49f9b52d242a3a9a754edb52124bcd63d46d98acb75c15f66ef5a5df559d2ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for miniadk-0.1.0-py3-none-any.whl:

Publisher: workflow.yml on Saglear/miniadk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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