Skip to main content

AgentKube-Mini

AgentKube-Mini

A tiny agent orchestration engine. Implements a task DAG, dependency-aware parallel scheduler, and event system for multi-agent pipelines — all in about 400 lines of Python with zero dependencies. The idea is to show how agent orchestration actually works under the hood.

Installation

pip install agentkube-mini

Quick start

Example usage

Define agents as simple functions, wire them into a DAG, and run:

from agentkube_mini import Agent, TaskGraph, Runtime

# define agents — each is just a name + function
research = Agent("research", lambda topic: f"data about {topic}")
analysis = Agent("analysis", lambda topic, deps: f"analysis of {deps['research']}")
writer   = Agent("writer",   lambda topic, deps: f"article based on {deps['analysis']}")
critic   = Agent("critic",   lambda topic, deps: f"score=9 for {deps['writer']}")

# wire the DAG
graph = TaskGraph()
graph.add(research)
graph.add(analysis, depends=["research"])
graph.add(writer,   depends=["analysis"])
graph.add(critic,   depends=["writer"])

# run it
result = Runtime(graph).run("AI agents")
print(result.outputs)

Output:

research → data about AI agents
analysis → analysis of data about AI agents
writer   → article based on analysis of data about AI agents
critic   → score=9 for article based on analysis of data about AI agents

The scheduler automatically figures out which agents can run in parallel (independent nodes run concurrently via ThreadPoolExecutor) and which must wait for dependencies. Events are emitted at each step (task_started, task_completed, task_failed) so you get observability for free.

Visualization

The task graph can print itself as text or as a Mermaid diagram:

print(graph.visualize())
# research -> analysis
# analysis -> writer
# writer -> critic

print(graph.to_mermaid())
# graph TD
#     research
#     research --> analysis
#     analysis --> writer
#     writer --> critic

Events and shared memory

Every run produces an event log and a shared memory dict that all agents write into:

from agentkube_mini import Runtime, EventBus

bus = EventBus()
bus.subscribe("task_failed", lambda e: print(f"ALERT: {e.task} failed"))

result = Runtime(graph, event_bus=bus).run("AI agents")

# event log
for ev in result.events:
    print(ev.type, ev.task)

# shared memory — every agent's output is accessible
result.memory["research"]  # → "data about AI agents"

Using with existing code

You don't have to rewrite your services. Wrap them with auto_agent, which auto-detects the function signature:

from agentkube_mini import auto_agent

# your existing function, unchanged
def my_research_service(topic: str) -> dict:
    return {"topic": topic, "facts": ["f1", "f2"]}

research = auto_agent("research", my_research_service)

See integration_example.py for a full working example with legacy service classes.

How it works

The core abstraction is: agents are nodes, dependencies are edges, the scheduler walks the DAG. That's the whole idea. If you understand this, you understand the center of every real multi-agent runtime — the rest (distributed workers, retries, message queues, state stores) is extensions on top.

Agent graph  →  Scheduler  →  Parallel execution + Events

File structure

agent.py               — the Agent dataclass (name + callable)
task_graph.py          — DAG: add nodes, validate, visualize
scheduler.py           — dependency-aware parallel scheduler
runtime.py             — thin wrapper around scheduler
events.py              — event bus with subscribe/emit/history
example.py             — the demo shown above
compat.py              — auto_agent adapter for existing code
smoke_test.py          — tiny correctness test
integration_example.py — legacy service adapter demo

Running tests

python3 smoke_test.py

License

MIT

Metadata

Release files for agentkube-mini 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentkube-mini 0.1.1
File Size Uploaded
agentkube_mini-0.1.1.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentkube-mini 0.1.1
File Interpreter ABI Platform
agentkube_mini-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / agentkube_mini-0.1.1.tar.gz

Download URL agentkube_mini-0.1.1.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6c69beeee3aedb3d680af33672f49cf3a94aa56eeb846edb65cba4df1664f9d6
BLAKE2b-256 checksum
How to use checksums
18ed06609b4fc11a3838ccf8a9ac77cc46a30fd2fbca8d7754f5ea2bfa15300c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / agentkube_mini-0.1.1-py3-none-any.whl

Download URL agentkube_mini-0.1.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
843c601d15aa18e81ccefe6a1553fdf3ade84f9c898ed15196496fc5694bcc58
BLAKE2b-256 checksum
How to use checksums
3b3500fe867414d504db8c8340f53bebdfc4f50dece2c6edb3256dba2e451009
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page