Skip to content

About

LangGraph-based agent loop runtime: CLI + Python library + MCP server. ReAct loop with tool calling, command-injection security layer, circuit breaker, append-only event log, and supervisor multi-agent mode.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agent-loop

LangGraph-based agent loop runtime: build and run multi-step autonomous agents with tool calling, conditional routing, and state persistence.

Two modes:

  1. CLI / Library — scripts/agent_loop.py, direct invocation or as a Python library
  2. MCP Server — scripts/mcp_server.py, exposes run_agent (single agent) and run_agents (supervisor multi-agent) tools to any MCP host

Features

  • ReAct loop architecture: START → call_model → [conditional] → execute_tools → (loop back) — the LLM decides its own tool sequence
  • Security layer (on by default): command templates are statically scanned for dangerous operations (rm, del, eval, subprocess, ...) at construction; parameter values are validated at call time — shell metacharacters are rejected as injection
  • Circuit breaker: identical tool calls without progress (default 3) inject a warning forcing a strategy change or conclusion
  • Append-only event log: every milestone (task start, tool call, breaker trip, end) written as an immutable JSON file — replayable, no locking needed
  • Structured status: completed / stalled / circuit_open / max_iterations
  • Supervisor pattern (run_agents): planner agent splits the task into N subtasks, sub-agents execute in parallel, results merged
  • Model-agnostic: works with any OpenAI-compatible API (OpenAI, Azure, local LM Studio, Ollama)

Quick start

pip install langgraph langchain langchain-core langchain-openai

python scripts/agent_loop.py \
  --task "Analyze the auth module" \
  --tools tools.json \
  --max-iter 10 \
  --verbose

Define tools as a JSON file — each tool maps to a CLI command with a JSON schema:

[
  {
    "name": "read_file",
    "description": "Read the contents of a file at the given path.",
    "parameters": {
      "type": "object",
      "properties": {
        "path": {"type": "string", "description": "Absolute path to the file"}
      },
      "required": ["path"]
    },
    "command": "python -c \"print(open('{path}', 'r', encoding='utf-8').read()[:4000])\""
  }
]

MCP registration

"mcp": {
  "agent-loop": {
    "type": "local",
    "command": ["python", "path/to/scripts/mcp_server.py"],
    "environment": {
      "OPENAI_API_KEY": "sk-xxx",
      "OPENAI_BASE_URL": "https://api.deepseek.com/v1",
      "AGENT_MODEL": "deepseek-chat"
    },
    "enabled": true
  }
}

Docs

  • SKILL.md — full usage guide, parameters, and decision framework
  • references/patterns.md — common agent design patterns and troubleshooting

Inspired by agent-hub (filesystem-based multi-agent coordination).

About

LangGraph-based agent loop runtime: CLI + Python library + MCP server. ReAct loop with tool calling, command-injection security layer, circuit breaker, append-only event log, and supervisor multi-agent mode.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages