🤖 AI Agents Module¶
Architecture, orchestration, tool-use loops, production guardrails, and interview preparation
Overview¶
AI agents are systems in which an LLM decides, in a loop, which tools to call and when to stop, rather than following a fixed code path. This module covers the engineering of production-grade agent systems — from single-agent ReAct loops to multi-agent coordination, MCP integration, and production deployment.
Contents¶
| # | Document | Description |
|---|---|---|
| 1 | Agent Fundamentals | Core architectures (ReAct, Plan-and-Execute, Orchestrator-Worker), memory, tool-use patterns |
| 2 | Agent Interview Questions | Staff-level Q&A with evaluation rubric |
| 3 | Agent Implementation Guide | Building agents: tool loops, tool registries, MCP integration |
| 4 | Agent Production Architecture | Deployment, guardrails, cost management, trade-offs |
| 5 | LangGraph Notes | Graph-based agent state machines, checkpointers, human-in-the-loop |
| 6 | Python Async & Await | asyncio concurrency for agents: tasks, timeouts, cancellation |
| 7 | Agent Observability | Tracing, metrics, OpenTelemetry GenAI conventions, evals in production |
| 8 | Multi-LLM Architecture | Routing, cost management, fallback chains across providers |
| 9 | Agent Deployment on ECS | Running agents on AWS ECS/Fargate: streaming, scaling, secrets |
| 10 | System, User & Assistant Roles | Message roles, instruction hierarchy, prompt-injection boundaries |
| 11 | Redis Lease | Distributed locking with TTL, fencing tokens |
| 12 | Search Autocorrect | Misspelling handling and query correction |
| 13 | Elasticsearch Internals | Shards, segments, inverted index, near-real-time search |
| 14 | Multi-LLM Production Ops | Token monitoring, rate limiting, caching, retries, A/B testing, alerting |
| 15 | Agent Memory Systems | Short-term, long-term and episodic memory; retrieval and compaction |
Implementation¶
- implementation/ — Working Python agents:
simple_react_agent.py— Basic ReAct loop with tool registryorchestrated_agent.py— Orchestrator-Worker pattern with async executionagent_with_mcp.py— Agent discovering/using tools via MCP protocolcommon/— Shared utilities: memory, guardrails, LLM client, tool registry
Tests¶
- tests/ — Pytest test suite:
test_simple_agent.py— Agent loop, input/output guardrails, parsingtest_orchestrated_agent.py— Worker execution, multi-agent coordination
Quick Start¶
cd ai-engineering/agents/
pip install -r implementation/requirements.txt
# Run the ReAct agent (uses mock LLM by default)
python -m implementation.simple_react_agent
# Run the orchestrator agent
python -m implementation.orchestrated_agent
# Run the MCP-connected agent (requires mcp>=2; it launches ../mcp/servers/calculator_server.py over stdio)
python -m implementation.agent_with_mcp
# Run tests
python -m pytest tests/ -v
Related Modules¶
- RAG Module — Knowledge retrieval for agents
- MCP Module — Protocol for agent-tool communication