MCPInstall

ai-agent-deep-dive-teaching-framework

A minimal teaching framework for understanding AI Agent architecture with core loop, fake LLM interface, and skill discovery system

Installs
194
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/reason-machines/ai-agent-skills --skill ai-agent-deep-dive-teaching-framework
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads ai-agent-deep-dive-teaching-framework automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

ai-agent-deep-dive-teaching-framework

Skill by ara.so — AI Agent Skills collection.

Overview

ai-agent-deep-dive is a teaching-focused Python project that demonstrates how to build a minimal AI Agent from scratch. It includes:

  • A core Agent loop implementation
  • A swappable LLM interface (currently using a fake LLM for teaching)
  • A skill discovery and loading system
  • CLI interface for interaction
  • Educational documentation and reports on AI Agent architecture

The project is designed to keep complexity minimal while showing the essential components every AI Agent needs. It's ideal for learning agent architecture before building production systems.

Installation

The project uses Poetry for dependency management.

# Clone the repository
git clone https://github.com/tvytlx/ai-agent-deep-dive.git
cd ai-agent-deep-dive

# Install dependencies
poetry install

# Verify installation
poetry run agt --help

Core Architecture

The teaching agent consists of three main components:

  1. Agent Core (src/agt/agent.py) - Main loop and execution logic
  2. CLI Interface (src/agt/cli.py) - Command-line entry point
  3. Skills System - Pluggable capabilities loaded from a skills directory

CLI Commands

Basic Usage

# Run agent with a simple query
poetry run agt "hello world"

# List available skills
poetry run agt --skills-dir ./skills --list-skills

# Specify custom skills directory
poetry run agt --skills-dir /path/to/skills "your query"

CLI Options

  • query - The input query for the agent (positional argument)
  • --skills-dir - Path to directory containing skill modules (default: ./skills)
  • --list-skills - Display all discovered skills and exit

Code Examples

Basic Agent Usage

from agt.agent import Agent

# Initialize agent with default fake LLM
agent = Agent()

# Run agent with a query
response = agent.run("What can you help me with?")
print(response)

Understanding the Agent Loop

from agt.agent import Agent

# The agent loop follows this pattern:
# 1. Receive user input
# 2. Send to LLM (currently fake)
# 3. Stream response back
# 4. Execute any triggered skills

agent = Agent(skills_dir="./skills")
result = agent.run("Calculate 2+2")

Custom LLM Interface

The project uses a fake LLM for teaching. To replace with a real LLM:

from agt.agent import Agent

class RealLLM:
    """Replace the fake LLM with real API calls"""
    
    def __init__(self, api_key=None):
        self.api_key = api_key or os.getenv("OPENAI_API_KEY")
    
    def stream_response(self, prompt: str):
        """Stream tokens from real LLM"""
        # Implementation would call actual API
        # and yield tokens as they arrive
        pass

# Extend Agent class to use real LLM
class ProductionAgent(Agent):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.llm = RealLLM()

Creating Custom Skills

Skills are Python modules placed in the skills directory:

# skills/calculator.py

def add(a: int, b: int) -> int:
    """Add two numbers together"""
    return a + b

def multiply(a: int, b: int) -> int:
    """Multiply two numbers"""
    return a * b

# Skills metadata (optional)
SKILL_METADATA = {
    "name": "calculator",
    "description": "Basic arithmetic operations",
    "functions": ["add", "multiply"]
}

Programmatic Agent Interaction

from agt.agent import Agent
import os

# Initialize with environment configuration
agent = Agent(
    skills_dir=os.getenv("AGENT_SKILLS_DIR", "./skills")
)

# Process multiple queries
queries = [
    "Hello, what can you do?",
    "Calculate something",
    "List your capabilities"
]

for query in queries:
    print(f"\nUser: {query}")
    response = agent.run(query)
    print(f"Agent: {response}")

Configuration

Environment Variables

# Example .env file
AGENT_SKILLS_DIR=./skills
OPENAI_API_KEY=your-api-key-here  # For when you replace fake LLM
LOG_LEVEL=INFO

Agent Configuration

from agt.agent import Agent

agent = Agent(
    skills_dir="./custom_skills",  # Custom skills location
    verbose=True,                   # Enable detailed logging
    max_iterations=10               # Limit agent loop iterations
)

Project Structure

ai-agent-deep-dive/
├── src/
│   └── agt/
│       ├── agent.py      # Core agent implementation
│       ├── cli.py        # CLI entry point
│       └── __init__.py
├── skills/               # Skill modules directory
├── docs/                 # Teaching documentation
├── pyproject.toml       # Poetry dependencies
└── README.md

Common Patterns

Pattern 1: Agent with Skill Discovery

from agt.agent import Agent
import os

# Agent automatically discovers skills in directory
agent = Agent(skills_dir="./skills")

# Skills are loaded and available during agent execution
response = agent.run("Use available skills to help me")

Pattern 2: Streaming Response Handler

from agt.agent import Agent

agent = Agent()

# The fake LLM demonstrates streaming pattern
# Real implementation would stream from API
def handle_stream(query: str):
    for chunk in agent.stream_query(query):
        print(chunk, end="", flush=True)
    print()  # Newline after stream completes

Pattern 3: Extending the Agent

from agt.agent import Agent

class CustomAgent(Agent):
    """Extended agent with custom behavior"""
    
    def pre_process(self, query: str) -> str:
        """Custom preprocessing"""
        return query.strip().lower()
    
    def post_process(self, response: str) -> str:
        """Custom postprocessing"""
        return response.upper()
    
    def run(self, query: str) -> str:
        query = self.pre_process(query)
        response = super().run(query)
        return self.post_process(response)

Learning Resources

The repository includes extensive documentation:

  • PDF Reports: Deep dive analysis of AI Agent architectures
    • ai-agent-deep-dive-v2.1.pdf - Includes memory systems chapter
    • ai-agent-deep-dive-v2.pdf - Core agent analysis
  • Teaching Docs: /docs directory with architectural explanations

Troubleshooting

Skills Not Loading

# Verify skills directory exists and has valid Python modules
import os

skills_dir = "./skills"
if not os.path.exists(skills_dir):
    os.makedirs(skills_dir)

# List skills to debug
from agt.cli import main
# Run: poetry run agt --list-skills

Import Errors

# Ensure you're in the project directory
cd ai-agent-deep-dive

# Reinstall dependencies
poetry install

# Verify installation
poetry run python -c "from agt.agent import Agent; print('OK')"

Poetry Not Found

# Install poetry
curl -sSL https://install.python-poetry.org | python3 -

# Or via pip
pip install poetry

# Verify
poetry --version

Next Steps

This teaching framework uses a fake LLM to demonstrate structure. To build a production agent:

  1. Replace the fake LLM with real API calls (OpenAI, Anthropic, etc.)
  2. Implement proper error handling and retries
  3. Add memory/context management
  4. Enhance skill execution with function calling
  5. Add logging and monitoring

Example Real LLM Integration:

import os
from openai import OpenAI

class OpenAILLM:
    def __init__(self):
        self.client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
    
    def stream_response(self, prompt: str):
        stream = self.client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": prompt}],
            stream=True
        )
        for chunk in stream:
            if chunk.choices[0].delta.content:
                yield chunk.choices[0].delta.content

This teaching project provides the architectural foundation — real integrations follow the same patterns but with production-grade implementations.

FAQ

What does the ai-agent-deep-dive-teaching-framework skill do?

A minimal teaching framework for understanding AI Agent architecture with core loop, fake LLM interface, and skill discovery system

How do I install ai-agent-deep-dive-teaching-framework?

Run npx skills add https://github.com/reason-machines/ai-agent-skills --skill ai-agent-deep-dive-teaching-framework in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/ai-agent-deep-dive-teaching-framework/ (personal) or .claude/skills/ai-agent-deep-dive-teaching-framework/ (project).

Which AI agents can use ai-agent-deep-dive-teaching-framework?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is ai-agent-deep-dive-teaching-framework safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains ai-agent-deep-dive-teaching-framework?

It is published by reason-machines in reason-machines/ai-agent-skills. It has 194 recorded installs.

More from reason-machines/ai-agent-skills

View all →

agency-agents-zh-skill

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents322 installs

agent-reach-internet-access

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents228 installs

agent-sprite-forge-2d-game-assets

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

Media & Creative216 installs

agentmemory-persistent-memory

reason-machines/ai-agent-skills

Add persistent memory to AI coding agents using agentmemory - remembers context, preferences, and decisions across sessions

AI & Agents216 installs

awesome-agent-skills

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents214 installs

oh-my-openagent-orchestration

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents211 installs

Popular ai & agents skills

View category →

google-agents-cli-publish

google/agents-cli

This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).

AI & Agents513.9K installs

google-agents-cli-eval

google/agents-cli

This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).

AI & Agents513.5K installs

skill-creator

anthropics/skills

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

OfficialAI & Agents416.4K installs

codex-pet

prime-skills/runcomfy-agent-skills

Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.

AI & Agents402.1K installs

full-output-enforcement

leonxlnx/taste-skill

Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.

AI & Agents401K installs

executing-plans

obra/superpowers

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

AI & Agents245.7K installs