A step-by-step, build-in-public project focused on creating a real task automation agent using modern agentic tooling.
This repository documents the incremental evolution of an AI agent โ starting from a minimal, working core and gradually adding planning, tools, memory, and control mechanisms.
Motto: AI For Everyone
Most "AI agent" demos stop at prompts.
This project focuses on inspectable, extensible systems that:
- Maintain explicit state
- Make decisions instead of hardcoded branching
- Use real tools
- Evolve incrementally without rewrites
Each phase adds one clear capability, while keeping the system runnable and understandable.
Phase 6 completely revamps the user interaction layer by introducing a powerful, interactive Terminal UI (TUI) powered by the rich Python library. It moves away from standard print statements to structured, visually appealing, and organized panel displays:
- Rich Terminal UI: Beautiful, organized panels for tasks, memory retrieval, agent execution, and results.
- Dynamic Task Layouts: Responsive formatting that auto-adjusts to terminal size for readability.
- Color-Coded Feedback: Instant visual cues for successful steps (Green), failures (Red), and intermediate reasoning (Yellow/Cyan).
- Graceful Visual Loops: Clear visual separation of the human-in-the-loop approval requests and their outcomes.
- Backward compatibility: All Phase 1-5 functionality (Memory, Fallbacks, Planners, Risk Classification, Approvals) sits powerfully underneath the new UI.
Flow with Approvals:
Input โ Memory Retrieval โ Analysis & Planning โ Risk Classifier โ Approval Node (If needed) โ Execution โ Result
Approval Modes:
NEVER_ASK: Executes silently without interrupting.ALWAYS_ASK: Forces a pause and human terminal prompt no matter what.AUTO(Smart): Checks the Risk Classifier. Bypasses the prompt ifSAFE/MODERATE, but stops forCRITICAL(e.g., dropping a file).
- Rich Visual Interface: Organized tables, panels, and live status displays
- Human-in-the-Loop: Active intercepts for dangerous executions (Phase 5)
- Granular Control: User specific rule table mapping natively via
config-approvals(Phase 5) - Intelligent caching: File metadata speeds up checks and reads (Phase 4)
- Tool learning: Tracks success and failure rates per tool (Phase 4)
- Conversation history: Uses recent tasks for context (Phase 4)
- Persistent storage: Stores logs in local SQLite database (Phase 4)
- Internet connectivity: Search web, fetch URLs, call APIs (Phase 3)
- Error resilience: Automatic retry with exponential backoff (Phase 3)
- Fallback intelligence: Creates alternative plans when primary fails (Phase 3)
User Input
โ
Memory Retrieval (Fetch Context)
โ
Complexity Analyzer (LLM)
โ
โโ SIMPLE โโโโโโโโโโโโโ โโ COMPLEX โโโโโโโโโโโโโโโโโโโโโโ
โ Simple Agent โ โ Planner โ
โ โ โ โ โ โ
โ Risk Classifier โ โ Risk Classifier Loop โ
โ โ โ โ โ โ
โ Approval Required? โโโโโโ Approval Required? โ
โ โ โ โ โ โ
โ Tools (if needed) โ โ Executor Loop โ
โ โ โ โ โ โ
โ Direct Result โ โ Error? โ Retry (3x backoff) โ
โโโโโโโโโโโฌโโโโโโโโโโโโ โ โ โ
โ โ Max Retries? โ Fallback Plan โ
โ โ โ โ
โ โ Coordinator โ
โ โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ
Memory Writer (Save Context)
โ
Final Output
13 LangGraph Nodes:
memory_retrieval: Pre-fetches task context, session history and file cachesanalyzer: Determines task complexityplanner: Creates step-by-step plansrisk_classifier: Grades danger payload of executing stepapproval_request: Pauses terminal loop to ask user for permissionapproval_decision: Conditionally steps execution forward or skips safelyexecutor: Executes individual steps with error handlingerror_handler: Analyzes failures, decides retry/fallbackfallback_planner: Creates alternative approachescoordinator: Compiles final results with error summarysimple_agent: Handles direct execution (Phase 1 behavior)tools: 10 tools (calculator, files, web, APIs, file deleter)memory_writer: Saves execution results, states, and telemetry to SQLite
- LangGraph โ Agent flow, state, and routing
- LangChain โ Tool abstractions
- Groq (Llama 3.3 70B Versatile) โ Fast, reliable LLM reasoning
- Tavily โ Web search API
- OpenWeatherMap โ Weather data API
- Python โ Core implementation
- dotenv โ Environment configuration
.
โโโ src/
โ โโโ approval/ # Risk grading and user approval loops
โ โ โโโ classifier.py # Risk grading logic for actions
โ โ โโโ logger.py # SQL User Decision logger
โ โ โโโ nodes.py # LangGraph node controllers for Approvals
โ โ โโโ preferences.py # SQLite rule interface
โ โโโ core/ # Agent orchestration
โ โ โโโ agent.py # Core LangGraph logic & Router mapping
โ โ โโโ config.py # Configuration and API keys
โ โ โโโ state.py # State tracking definition
โ โ โโโ ui.py # Shared rich UI theme components
โ โโโ memory/ # Persistence and context
โ โ โโโ manager.py # SQLite database interaction layer
โ โ โโโ nodes.py # Memory retrieval and saving Graph nodes
โ โ โโโ schema.py # SQLite schema building
โ โโโ tools/ # LLM Tools
โ โโโ tools.py # File, Web, API, and System tools
โโโ scripts/ # Helper scripts
โโโ tests/ # Test suite
โโโ main.py # CLI with Phase 6 TUI interface
โโโ pyproject.toml # Dependency config (uv)
โโโ agent_memory.db # Local SQLite database (ignored)
โโโ README.md
pip install -r requirements.txt
# or with uv:
uv syncCreate a .env file:
GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
OPENWEATHER_API_KEY=your_openweather_api_key_hereGet your API keys:
- Groq: https://console.groq.com/ (free)
- Tavily: https://tavily.com/ (free tier)
- OpenWeatherMap: https://openweathermap.org/api (free tier)
python memory_schema.py
โ ๏ธ IMPORTANT NOTE FOR UI: Because this phase uses therichlibrary for an advanced Terminal UI (TUI), please maximize or significantly increase the size of your terminal window BEFORE running the agent. If your terminal is too narrow, the rich formatted panels will wrap awkwardly and ruin the neat interface experience.
python main.py
# or with uv:
uv run python main.pySimple tasks (direct execution):
Calculate 25 * 16Search for LangGraph documentationWhat's the weather in London?
Complex tasks (multi-step planning):
Create a test file with hello world and analyze it
Memory specific tasks:
stats-> See memory status and tool performance- Type a repeat task -> Watch it execute faster (File Cache)
- Reference a past item -> E.g., "Analyze the file from earlier"
Approval specific tasks:
show-rules-> View current safety rulesconfig-approvals-> Modify safety rules dynamicallyapproval-history-> View local DB tracking history
- Basic decision-making agent
- Tool usage (calculator, text analyzer)
- Simple state management
- Direct task execution
- Automatic complexity detection
- Multi-step planning and execution
- File system operations
- Context preservation across steps
- Intelligent routing
- Web search (Tavily API)
- HTTP requests to any REST API
- URL content fetching
- Weather API integration
- Error handling with retry logic
- Exponential backoff (1s, 2s, 4s)
- Fallback planning for failures
- Task History Database
- Session/Context memory awareness
- File metadata caching
- Faster execution times through caching
- Human-in-the-loop dynamic approvals
- Safe / Moderate / Critical risk classification mapping
- SQLite-backed preference engine rules (
ALWAYS_ASK,NEVER_ASK,AUTO) - SQLite-backed User decision logger
- Safe fallback trapping for looping simple agents via
ENDgraphs - Command line utility modifiers (
show-rules,config-approvals,approval-history)
- NEW: Full
richpowered Terminal UI (TUI) - NEW: Structured visual components (Panels, Tables, Formatting)
- NEW: Live display separation of tasks, memory, execution, and outputs
- NEW: Clean exception formatting and layout auto-adjustment
LangGraph enables:
- Explicit state transitions: No hidden control logic
- Deterministic routing: Clear decision points
- Inspectable behavior: Every step is visible
- Incremental evolution: Add capabilities without rewrites
- Backward compatibility: Previous phases continue working
- Error resilience: Production-ready failure handling
This project treats agents as software systems, not prompt tricks.
Planned future phases:
- Phase 7: Multi-agent collaboration
- Phase 8: Deep UI integration / Docker deployment
Each phase builds incrementally without breaking previous functionality.
This architecture is suitable for:
- Production automation systems: Resilient multi-step workflows
- AI-assisted research: Web search + analysis + reporting
- API integration workflows: Connect multiple services reliably
- Weather-aware applications: Real-time weather data processing
- Controlled agent execution: Transparent decision making with error handling
- Educational agent experiments: Clear, inspectable architecture
This project is intentionally developed in public to:
- Encourage learning through transparency
- Share real implementation patterns
- Avoid agent hype and black-box behavior
- Demonstrate incremental system evolution
Feedback, ideas, and discussion are welcome.
MIT License โ free to use, modify, and learn from.
Muhammad Saad
AI โข Automation โข Agentic Systems
Website: https://muhammadsaad.dev
"Good agents are not magical.
They are well-designed systems."