An experimental repository for building, exploring, and comparing AI Agent architectures and frameworks. This project focuses on understanding core agentic patterns—such as the ReAct (Reasoning + Acting) framework from first principles—as well as experimenting with modern agent libraries (Smolagents, LlamaIndex, LangChain) and multi-agent orchestration.
- ReAct Agent from Scratch: Full custom implementation of the Thought-Action-Observation loop using raw JSON structured output and OpenRouter without relying on heavy frameworks.
- Custom Tooling System: A lightweight function decorator (
@tool) and wrapper class (Tool) that dynamically inspects signatures and docstrings. - Hugging Face Smolagents Integration:
- CodeAgent: Code-execution agent with custom
@toolfunctions and class-basedToolsubclasses. - RAG Agent: Retrieval-Augmented Generation using LangChain's
BM25RetrieverandRecursiveCharacterTextSplitter. - Multi-Agent Orchestration: Hierarchical manager agent delegating tasks to sub-agents (
web_search_agentandrag_agent). - Agent Security: Python code execution sandbox control and import whitelisting.
- CodeAgent: Code-execution agent with custom
- LlamaIndex Core: Experiments with open-source LLMs (e.g., Qwen2.5-Coder) via
HuggingFaceInferenceAPI. - FastAPI API Backend: Production-ready REST server featuring Bearer token authentication and Role-Based Access Control (RBAC).
agentic-ai/
├── src/
│ ├── core/ # Core utilities and custom tooling primitives
│ │ ├── config.py # Environment configuration (Pydantic Settings)
│ │ ├── tool.py # Custom Tool class encapsulation
│ │ └── decorator.py # @tool decorator for dynamic function inspection
│ ├── react_agent/ # ReAct pattern implementation from scratch
│ │ └── react_agent.py # Custom Thought-Action-Observation loop
│ ├── smolagents_core/ # Experiments with Hugging Face smolagents
│ │ ├── code_agent.py # CodeAgent with custom tools
│ │ ├── rag_agent.py # BM25-based Retrieval Agent
│ │ ├── multi-agent.py # Manager-Worker hierarchical multi-agent system
│ │ └── agent_security.py # Security settings & import restrictions
│ ├── llamaindex_core/ # LlamaIndex LLM integration
│ │ └── agent.py # Hugging Face Inference API agent setup
│ ├── voice_agent/ # Voice agent workspace (experimental)
│ │ └── agent.py # Placeholder for speech interaction
│ └── main.py # FastAPI app with Bearer Auth & RBAC
├── .env.example # Environment configuration template
├── makefile # Useful CLI shortcuts
├── pyproject.toml # Dependencies and project metadata
└── README.md # Project documentation
Implements the core Reasoning + Acting loop from the ground up:
- Prompting: Supplies a system prompt defining available tools and strictly enforcing raw JSON outputs.
- Loop Execution:
- Parses LLM output into
thought,action, orfinal_answer. - Executes registered tools dynamically from
TOOL_REGISTRY. - Appends observations back to message history for multi-step reasoning.
- Parses LLM output into
tool.py: Encapsulates tool metadata (name,description,arguments,outputs) and makes tool instances callable.decorator.py: A@tooldecorator utilizing Python'sinspectmodule to automatically generate tool specifications from docstrings and parameter type hints.
- Custom Tools & CodeAgent (
code_agent.py): Defines custom tools (e.g. menu recommenders, Gotham catering finders, theme generators) executed by aCodeAgent. - RAG Retrieval Agent (
rag_agent.py): Indexes structured knowledge intoBM25Retrieverdocuments and provides a semantic retrieval tool to a dedicated RAG agent. - Multi-Agent Orchestration (
multi-agent.py): Implements a manager agent that delegates sub-tasks to aweb_search_agentand arag_agent. - Agent Security (
agent_security.py): Restricts Python environment execution usingadditional_authorized_importsanduse_e2b_executor.
Interactions with open models (such as Qwen/Qwen2.5-Coder-32B-Instruct) hosted on Hugging Face using HuggingFaceInferenceAPI.
FastAPI application with dependency-injection based authentication (HTTPBearer) and authorization (require_role, require_permission).
- Python:
>= 3.13 - Package Management:
uv - Frameworks & Libraries:
smolagentslangchain,langchain-community,langchain-corellama-index-llms-huggingface-api,llama-index-embeddings-huggingfacefastapi,uvicorn,pydantic,pydantic-settingsrank-bm25openrouter,transformers,torch
Install uv (recommended) or use standard Python 3.13+.
# Clone the repository
git clone https://github.com/your-username/agentic-ai.git
cd agentic-ai
# Create virtual environment and install dependencies
uv syncCreate a .env file in the project root:
OPEN_ROUTER_API_KEY=your_openrouter_api_key_hereHF_TOKEN=your_huggingface_token_hereuv run python -m src.react_agent.react_agent# Single CodeAgent with Custom Tools
uv run python -m src.smolagents_core.code_agent
# Hierarchical Multi-Agent System
uv run python -m src.smolagents_core.multi_agent
# Security-Constrained Agent
uv run python -m src.smolagents_core.agent_securityuv run python -m src.llamaindex_core.agent# Using Makefile
make run
# Or directly with Uvicorn
uv run uvicorn main:app --reload --app-dir src --host 127.0.0.1 --port 8081Once running, view the interactive API docs at http://127.0.0.1:8081/docs.
Contributions, feedback, and new agent experiment ideas are welcome! Feel free to open an issue or submit a pull request.