Main autonomous orchestrator agent that coordinates sub-worker agents via MCP.
Project description
Agent_head โ Main Autonomous Orchestrator
Agent_head is the central orchestrator agent for the orchestra multi-agent system. It coordinates multiple specialized Worker Agents and direct MCP (Model Context Protocol) tool servers through a unified LangGraph ReAct loop. This enables complex, multi-step tasks that require coordination across different domains and tools.
Agent_head can also natively run as an MCP server itself or as a REST API Backend, enabling you to build expansive agent networks spanning multiple orchestrators collaborating on heavy computation tasks.
๐ Documentation
Detailed system mechanics and configuration guides have been moved to dedicated documentation files:
- capabilities and User Guide: Explore the different operational modes, details on Multi-Agent brains, native tooling details, and
config.yamlbreakdowns. - Technical Implementation: Deep dive into the internal component architecture (LangGraph loop, summarizers, loading systems).
What is Agent_head?
Agent_head acts as the highly-agile "brain" of your software interface:
- Autonomous Execution: Uses LangChain/LangGraph for reasoning and tool calling
- Multi-Agent Coordination: Spawns and delegates tasks to specialized worker agents
- MCP Server Mode: Expose the orchestrator as an MCP server for other agents/clients
- Agent Networking: Connect multiple Agent_head instances together with shared sessions
- MCP Integration: Connects to any MCP-compatible tool servers
- Persistent Session History: Full conversation archive in SQLite โ never lost, even after summarisation
- Memory & Context: Maintains conversation history, facts, and auto-injects relevant context
- Interactive & Batch Modes: REPL interface or single-shot task execution
- Rich Logging: Per-job structured logs for debugging and auditing
- API Server: REST API with streaming SSE for programmatic access
Architecture
โโโโโโโโโโโโโโโโ
โ Claude โ
โ Desktop / โ โ External MCP clients
โ Cursor / etc โ
โโโโโโโโฌโโโโโโโโ
โ (MCP)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Agent_head โ
โ (Orchestrator + MCP Server) โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ LangGraph โ โ Memory โ โ MCP Server โ โ
โ โ ReAct Agent โ โ (RAG) โ โ (8 tools exposed) โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Summarizer โ โ Sessions โ โ Progress Streaming โ โ
โ โ (windowed) โ โ (SQLite) โ โ (SSE / ctx.info) โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโผโโโโโโ โโโโโโโโผโโโโโโ โโโโโโโโผโโโโโโ
โ Worker โ โ Worker โ โ MCP โ
โ Agent A โ โ Agent B โ โ Tools โ โ filesystem, search, etc.
โ (Agent_a) โ โ (Agent_a) โ โ (direct) โ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Agent Network (optional) โ
โ โ
โ Agent_head โโโSSE/HTTPโโโบ Agent_head โ
โ โ โ โ
โ Agent_head โโโstdioโโโบ Agent_head โ
โ โ
โ Shared sessions, multi-agent identity โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key Components
| File | Purpose |
|---|---|
main.py |
CLI entry point โ REPL, single-shot, session management |
api/server.py |
FastAPI REST + SSE server |
core/mcp_server.py |
MCP server mode (8 tools exposed) |
core/config_loader.py |
Typed configuration loading |
core/mcp_loader.py |
MCP client/server connection management |
core/memory.py |
Long-term memory backends |
core/conversation_summarizer.py |
Rolling history compression (windowed) |
core/history.py |
Abstract session history backend interface |
core/history_sqlite.py |
SQLite session persistence (working copy + full archive) |
core/llm.py |
LLM provider factory |
core/image_tools.py |
Image read / save / screenshot / OCR |
core/audio_tools.py |
Audio transcribe / TTS / record / play |
core/job_logger.py |
Structured per-job logging |
config.yaml |
Main configuration file |
Features
- Multi-Modal LLM Support: Ollama, OpenAI, Google Gemini, Anthropic, AWS Bedrock, NVIDIA NIM
- Worker Agent Delegation: Automatic task routing to specialists
- MCP Server Mode: Expose the orchestrator as an MCP server with 8 tools
- Agent Networking: Connect multiple agents โ shared sessions, identity tagging, supervisor monitoring
- All MCP Transports: stdio, SSE, and Streamable HTTP
- Configurable Progress Streaming: None / Summary / Full verbosity per call
- Direct MCP Tools: Filesystem, shell execution, web scraping, etc.
- Memory System: Fact storage and semantic search (RAG / ChromaDB)
- Persistent Session History: Two-layer SQLite storage โ windowed working copy for the LLM, unabridged archive for debugging
- Auto-Context Injection: Relevant memory auto-fed to LLM before each turn
- Rolling Summarisation: Keeps the LLM context window bounded; full history still preserved in archive
- Image & Audio Tools: Screenshot, OCR, TTS, transcription, recording
- Notification Listening: Real-time tool-change monitoring via Agent_notify
- Structured Logging: Per-job logs with full traces
- Graceful Error Handling: Tool failures don't crash the agent
Installation
Prerequisites
- Python 3.10+
uvpackage manager (recommended) orpip- For Ollama: Running Ollama server with models pulled
- For OpenAI / Gemini / Anthropic: API keys configured
Setup using UV
uv tool install --force git+https://github.com/tharindumendis/agent_orchestrator_template.git
Setup via Source
# Clone the repo
git clone <repository-url>
cd agent_orchestrator_template
# Create virtual environment
uv venv .venv
# Activate environment (Windows)
.venv\Scripts\activate
# Install dependencies
uv sync
# Or with pip
pip install -e .
Development Setup
uv sync --group dev
# Or
pip install -e ".[dev]"
Configuration
Run the setup wizard to generate a config in the current directory:
agent-head --setup
This creates .agents/config.yaml which is auto-loaded on next run. Edit it to configure models, workers, memory, etc.
Agent Configuration
agent:
name: "OrchestratorAgent"
version: "1.0.0"
debug: false # true โ writes full prompt/response logs to .agents/logs/runs/
system_prompt: |
You are a powerful autonomous orchestrator agent...
max_iterations: 50
Model Configuration
model:
provider: "ollama" # "ollama" | "openai" | "gemini" | "anthropic" | "bedrock" | "nvidia"
model_name: "qwen3:32b"
temperature: 0.0
base_url: "http://localhost:11434" # Ollama only
api_key: "" # OpenAI / Gemini / Anthropic
Worker Agents
worker_agents:
- name: "core-agent"
description: "General-purpose worker"
command: "agent-mcp"
args: []
env:
WORKER_AGENT_CONFIG: "./service_config/worker_config.yaml"
Direct MCP Clients
mcp_clients:
- name: "filesystem"
command: "npx.cmd"
args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
- name: "shell"
command: "npx.cmd"
args: ["-y", "shell-exec-mcp"]
Memory Configuration
memory:
enabled: true
backend: "rag" # "rag" (ChromaDB) or "jsonl"
memory_dir: "./memory"
max_save_length: 500
auto_feed_top_k: 3 # chunks injected before each turn
auto_feed_category: "all" # "all" | "history" | "facts"
rag_server:
command: "uvx"
args: ["agent-rag-mcp"]
env:
RAG_CONFIG: "./service_config/rag_config.yaml"
Chat History (Session Persistence)
chat_history:
backend: "sqlite"
connection_string: "./session_db/sessions.db"
Two tables are maintained automatically:
| Table | Contents | Trimmed? |
|---|---|---|
sessions |
Working copy โ windowed slice fed to LLM | Yes (after summarisation) |
session_archive |
Full archive โ every message ever sent | Never |
Summarizer
summarizer:
enabled: true
summarize_every_n_messages: 8 # compress after this many new Human+AI messages
keep_recent_messages: 8 # keep this many raw messages for the LLM feed
save_to_memory: true # persist extracted facts to long-term memory
model: # can be a lighter/cheaper model than the main LLM
provider: "ollama"
model_name: "qwen3:8b"
temperature: 0
Note: Summarisation only shrinks the working copy fed to the LLM. The full unabridged conversation is always preserved in the
session_archivetable and accessible viaGET /history/sessions/{id}/full-export.
Usage
Interactive REPL
agent-head
This command seamlessly creates the .agents hidden folder in your working directory and instantiates config.yaml alongside specialized agent configs, keeping your agent logic tightly bound to your project environment.
Starts an interactive prompt. History is always saved โ the session automatically resumes from where you left off. Type quit or press Ctrl-C to exit.
Session Modes
# Default โ uses the "default" session, fully persistent
agent-head
# Named session โ useful for keeping separate project contexts
agent-head --session my-project
# Ephemeral โ no persistence, history is lost on exit
agent-head --session no
| Flag | Session ID | Persistence |
|---|---|---|
| (none) | "default" |
โ Always saved |
--session myname |
"myname" |
โ Always saved |
--session no |
(none) | โ Ephemeral, lost on exit |
Running the Orchestrator
Command Line Mode (REPL):
agent-head --task "Analyse the codebase and suggest improvements"
# With a named session for memory continuity
agent-head --session myproject --task "Continue where we left off"
Single-Shot Prompting:
agent-head --config /path/to/custom_config.yaml
MCP Provider Mode:
# OpenAI
agent-head --provider openai --model gpt-4o --api-key sk-your-key
# Gemini
agent-head --provider gemini --model gemini-2.5-flash --api-key AIza...
# Ollama (local)
agent-head --provider ollama --model llama3.3:70b
Export Config for Editing
# Export to current directory (.agents/ subfolder)
agent-head --setup
# Export to a specific project directory
agent-head --setup /path/to/my-project
API Server
agent-api # http://0.0.0.0:8000
agent-api --port 9001
agent-api --config /path/to/config.yaml
Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/health |
Liveness check |
GET |
/sessions |
List live sessions |
POST |
/sessions |
Create / resume a session |
GET |
/sessions/{id} |
Session metadata |
DELETE |
/sessions/{id} |
Clear session |
POST |
/sessions/{id}/chat |
Send message โ SSE stream |
POST |
/sessions/{id}/shutdown |
Tear down agent (keep history) |
GET |
/history/sessions |
List all saved session IDs |
GET |
/history/sessions/{id}/export |
Export working-copy history (JSON) |
GET |
/history/sessions/{id}/full-export |
Export full archive (JSON) โ never trimmed |
SSE Event Types
{"type": "tool_call", "name": "...", "args": {...}}
{"type": "tool_result", "name": "...", "content": "..."}
{"type": "token", "content": "..."} // intermediate AI text
{"type": "done", "content": "..."} // final answer
{"type": "error", "content": "..."} // something went wrong
MCP Server Mode
Run Agent_head as an MCP server so other agents, Claude Desktop, or Cursor can connect:
# stdio transport (default โ Claude Desktop, Cursor, other agent_mcp instances)
agent-mcp
agent-mcp --config /path/to/config.yaml
# SSE transport (LAN / internet agent networks)
agent-mcp --transport sse --port 9000 --host 0.0.0.0
# Streamable HTTP (modern MCP standard, production use)
agent-mcp --transport http --port 9000
8 MCP tools exposed:
| Tool | Description |
|---|---|
orchestrate_task |
One-shot task execution |
create_session |
Create or join a persistent session with agent identity |
chat |
Multi-turn conversation in a session |
list_sessions |
List all active sessions |
get_session_history |
Retrieve conversation history |
list_agents |
List configured workers & tools |
get_status |
Agent health + workload (for supervisors) |
close_session |
Tear down a session and persist history |
Session History โ How It Works
Agent_head uses a two-layer storage model so you never lose conversation history:
Every turn
โ
โโโบ append_to_archive() โ PERMANENT โ every message, never trimmed
โ
โโโบ save_session() โ WORKING COPY โ windowed slice for LLM input
โ
โโโบ [if threshold hit] summarize()
โ
โโโบ save_session(trimmed_history) โ WORKING COPY shrinks
(archive stays untouched)
On session resume:
- LLM is fed the working copy (summary + recent N messages)
- Full archive is available via
GET /history/sessions/{id}/full-exportfor debugging
Logs and Debugging
Debug Mode
# config.yaml
agent:
debug: true
When enabled, every prompt fed to the LLM is written to .agents/logs/runs/<session_id>.log.
Job Logs (MCP mode)
Each MCP task creates a structured log in the configured log_dir:
logs/mcp/jobs/
โโโ 2025-04-20_12-00-00_abc123.log
โโโ 2025-04-20_12-05-30_def456.log
Session Debug Log (REPL mode)
.agents/logs/runs/
โโโ default.log โ default session
โโโ my-project.log โ --session my-project
โโโ 20250420_120530.log โ ephemeral --session no
Troubleshooting
Worker agents not connecting
- Check paths / commands in
config.yaml - Ensure worker virtual environments are activated
- Verify the worker command is on PATH (e.g.
agent-mcp)
MCP tools failing
npx @modelcontextprotocol/server-filesystem --help # verify install
- Check transport settings (stdio vs SSE vs HTTP)
- Look for port conflicts
Memory not working
- Check ChromaDB installation:
pip show chromadb - Verify
memory/directory has write permissions - Ensure the RAG server command (
uvx agent-rag-mcp) is installed
History / archive not saving
- Confirm
chat_history.backend: "sqlite"in config - Check that
connection_stringpath is writable - Verify you are NOT using
--session no(ephemeral disables persistence)
Performance Tuning
- Lower
summarize_every_n_messagesto compress more aggressively - Set
keep_recent_messages: 4-6for smaller context windows - Use a lighter model for the summarizer (separate
summarizer.modelconfig) - Reduce
max_iterationsfor faster single-turn responses
Project Structure
Agent_head/
โโโ main.py # CLI entry point (REPL + single-shot)
โโโ api/
โ โโโ server.py # FastAPI REST + SSE server
โโโ core/
โ โโโ agent.py # LangGraph ReAct agent
โ โโโ mcp_server.py # MCP server mode (8 tools)
โ โโโ config_loader.py # Typed config loading
โ โโโ mcp_loader.py # MCP client connections
โ โโโ llm.py # LLM provider factory
โ โโโ memory.py # Memory backends
โ โโโ memory_rag.py # RAG memory (ChromaDB)
โ โโโ history.py # Abstract history backend
โ โโโ history_sqlite.py # SQLite: working copy + full archive
โ โโโ conversation_summarizer.py # Rolling history compression
โ โโโ image_tools.py # Image read/save/screenshot/OCR
โ โโโ audio_tools.py # Audio transcribe/TTS/record/play
โ โโโ skill_loader.py # Skills discovery and injection
โ โโโ job_logger.py # Structured job logging
โโโ skills/ # Skills directory (SKILL.md files)
โโโ docs/
โ โโโ mcp-server.md # MCP server documentation
โโโ config.yaml # Default config
โโโ pyproject.toml # Package config
โโโ .agents/ # Local project config (auto-created by --setup)
โ โโโ config.yaml
โ โโโ service_config/
โ โโโ logs/runs/ # Per-session debug logs
โ โโโ skills/ # Project-local skills
โโโ memory/ # Long-term memory storage
โโโ service_config/ # Worker + service configs
Development
Adding New Features
- New Tools: Create a
@lc_tooldecorated function and add it toall_toolsinmain.py/api/server.py/core/mcp_server.py - New LLM Providers: Add a branch in
core/llm.py'sget_llm()factory - New Memory Backends: Implement
ConversationHistoryBackendincore/history.py - New Skills: Create
skills/<name>/SKILL.mdโ auto-discovered, no code changes needed
Testing
pytest
pytest --cov=core --cov-report=html
Contributing
- Fork the repository
- Create a feature branch
- Make changes with tests
- Submit a pull request
Code style: black formatting, PEP 8, type hints, docstrings.
License
MIT License โ see LICENSE file for details.
Changelog
v1.2.0
- Full Session Archive: Two-layer SQLite storage โ
sessions(windowed, LLM feed) +session_archive(append-only, never trimmed). Full history preserved even after summarisation. GET /history/sessions/{id}/full-export: New API endpoint to retrieve the complete, unabridged session conversation.- Default Session: REPL now always persists โ no
--sessionflag defaults to"default"session. Use--session nofor ephemeral (no persistence) mode. - System Prompt Guarantee: System prompt is always position-0 in conversation history on resume, even if summarisation had previously trimmed it.
mcp_server.pyBug Fixes: Fixeddatetime.now()crash (was calling method on module, not class), fixed image tools loading insideexceptblock (only loaded when memory failed), added archive support.- Anthropic / Bedrock Support: Added provider support in
core/llm.py.
v1.1.0
- MCP Server Mode: Agent_head can now run as an MCP server (
agent-mcp) - Agent Networking: Multi-agent shared sessions with identity tagging
- 8 MCP Tools: orchestrate_task, chat, create_session, list_sessions, get_session_history, list_agents, get_status, close_session
- Configurable Progress Streaming: none / summary / full verbosity
- All MCP Transports: stdio, SSE, Streamable HTTP
- Image Tools: read, save, screenshot, OCR
- Audio Tools: transcribe, TTS, save, record, play, speak
v1.0.0
- Initial release
- Multi-agent orchestration
- MCP integration
- Memory system
- REST API
- Interactive REPL
For more information, see the orchestra system documentation.
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 agento_template-1.0.0.tar.gz.
File metadata
- Download URL: agento_template-1.0.0.tar.gz
- Upload date:
- Size: 984.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
379cf75f5ec78cca8e16b7670e05be6b2852ca7153218be5862b31396d139e93
|
|
| MD5 |
256d71e358a9a25c67aaf3afbb0e946a
|
|
| BLAKE2b-256 |
420658bc9c5bdbcb3145d6a2be13bd33f527a92897d67ebdb088d7b50eddc65a
|
File details
Details for the file agento_template-1.0.0-py3-none-any.whl.
File metadata
- Download URL: agento_template-1.0.0-py3-none-any.whl
- Upload date:
- Size: 163.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdcf1ed4fa1dd1b19b216d70c75b24a840cc2029acccd531b7c6565850a83773
|
|
| MD5 |
fa904c670e71f4a85bf767752fc74357
|
|
| BLAKE2b-256 |
fd2f30e7052c955913b89f53357b3247ed16e3db1945928fd7e63aff985143ec
|