Metadata-Version: 2.4
Name: micro-agent-router
Version: 0.1.0
Summary: A zero-dependency, ultra-lightweight state machine for building agentic AI workflows without heavy frameworks.
Author-email: Encephos <magiltraun@gmail.com>
Project-URL: Homepage, https://github.com/Encephos/micro-agent-router
Keywords: llm,agent,workflow,state-machine,langgraph,zero-dependency
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# micro-agent-router

[![PyPI version](https://img.shields.io/pypi/v/micro-agent-router.svg)](https://pypi.org/project/micro-agent-router/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

A zero-dependency, ultra-lightweight state machine for building agentic AI workflows. It gives you the routing power of LangGraph, without the steep learning curve and massive framework bloat.

## The Problem
Building Agentic workflows (like a Researcher LLM passing data to a Writer LLM) requires a state machine. Frameworks like LangGraph or AutoGen are powerful but incredibly heavy. They require you to learn custom decorators, specific graph compiling steps, and complex state management classes. 

Sometimes, you just want to run standard Python functions in a loop based on their outputs.

## The Solution
`micro-agent-router` is a pure Python library that acts as a simple traffic controller. You register standard Python functions as "nodes". Each function just returns a dictionary telling the router where to go `next`. 

## Installation
```bash
pip install micro-agent-router
```

## Usage 
Here is a full agentic workflow (Writer -> Reviewer) in just a few lines of vanilla Python:
```python
from micro_agent_router import MicroAgentRouter

# 1. Define your standard Python functions (Nodes)
def writer_agent(state: dict):
    print("Writing article...")
    state["content"] = "This is a great article."
    
    # Just return where to route next!
    return {"next": "reviewer_agent", "data": state}

def reviewer_agent(state: dict):
    print("Reviewing article...")
    # Add your LLM logic here to decide if it's good or bad
    is_good = True 
    
    if is_good:
        state["status"] = "published"
        return {"next": "__end__", "data": state} # Exits the loop
    else:
        state["status"] = "needs_revision"
        return {"next": "writer_agent", "data": state} # Send it back!

# 2. Wire them up
router = MicroAgentRouter()
router.add_node("writer_agent", writer_agent)
router.add_node("reviewer_agent", reviewer_agent)

# 3. Set the entry point and run
router.set_start("writer_agent")
final_state = router.run(initial_data={"topic": "AI Agents"})

print(final_state)
# Output: {'topic': 'AI Agents', 'content': 'This is a great article.', 'status': 'published'}
```

## Features
* **Zero Dependencies:** Pure standard library.
* **Infinite Loop Protection:** Built-in max_steps to prevent agents from getting stuck in eternal loops and draining your API budget.
* **Transparent State:** The state is just a standard Python dictionary passed between your functions. No magic classes.
