Skip to content

Textbook: Designing Autonomous AI Agents

Version: 2.0
Author: Kirill Shvakov
For Course: AI Agent Course
Target Audience: Programmers who want to build production AI agents

Translations


📚 Table of Contents

Part I: Fundamentals

Part II: Practice-first (build an agent)

Part III: Architecture and Runtime Core

Part IV: Practice (case studies/practices)

Part V: Platform Infrastructure/Security

Part VI: Production Readiness

Appendices


🗺️ Reading Path

  1. Start with Preface — learn what an agent is and how to use this textbook
  2. Study LLM Physics — the foundation for understanding everything else
  3. Master Prompting — the foundation of working with agents
  4. Build a working agent:
  5. Tools and Function Calling — the agent's "hands"
  6. Autonomy and Loops — how agents work in loops
  7. Safety and Human-in-the-Loop — protecting against dangerous actions
  8. Expand capabilities:
  9. RAG and Knowledge Base — working with documentation
  10. Multi-Agent Systems — teams of specialized agents
  11. Evals and Reliability — testing agents
  12. Dive deeper into architecture:
  13. Agent Anatomy — components and their interactions
  14. Planning and Workflow Patterns — planning complex tasks
  15. State Management — execution reliability
  16. Agent Memory Systems — long-term memory
  17. Context Engineering — context management
  18. Practice: Complete laboratory assignments alongside reading chapters

For Experienced Programmers

You can skip basic chapters and go directly to:

Quick Track: Core Concepts in 10 Minutes

If you're an experienced developer and want to quickly understand the essence:

  1. What is an agent?
  2. Agent = LLM + Tools + Memory + Planning
  3. LLM is the "brain" that makes decisions
  4. Tools are the "hands" that perform actions
  5. Memory is history and long-term storage
  6. Planning is the ability to break down a task into steps

  7. How does the agent loop work?

    While (task not solved):
      1. Send history to LLM
      2. Get response (text or tool_call)
      3. If tool_call → execute tool → add result to history → repeat
      4. If text → show user and stop
    

  8. Key points:

  9. LLM doesn't execute code. It generates JSON with an execution request.
  10. Runtime (your code) executes real Go functions.
  11. LLM doesn't "remember" the past. It processes it in messages[], which Runtime collects.
  12. Temperature = 0 for deterministic agent behavior.

  13. Minimal example:

    // 1. Define tool
    tools := []openai.Tool{{
        Function: &openai.FunctionDefinition{
            Name: "check_status",
            Description: "Check server status",
        },
    }}
    
    // 2. Request to model
    resp, _ := client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
        Model: openai.GPT3Dot5Turbo,
        Messages: []openai.ChatCompletionMessage{
            {Role: "system", Content: "You are a DevOps engineer"},
            {Role: "user", Content: "Check server status"},
        },
        Tools: tools,
    })
    
    // 3. Check tool_call
    if len(resp.Choices[0].Message.ToolCalls) > 0 {
        // 4. Execute tool (Runtime)
        result := checkStatus()
        // 5. Add result to history
        messages = append(messages, openai.ChatCompletionMessage{
            Role: "tool",
            Content: result,
        })
        // 6. Send updated history back to model
    }
    

  14. What to read next:

  15. Chapter 03: Tools — detailed protocol
  16. Chapter 04: Autonomy — agent loop
  17. Chapter 09: Agent Anatomy — architecture

After Completing the Main Course

After studying chapters 1-16, proceed to:


🔗 Connection with Laboratory Assignments

Textbook Chapter Corresponding Laboratory Assignments
01. LLM Physics Lab 00 (Capability Check)
02. Prompting Lab 01 (Basics)
03. Tools Lab 02 (Tools), Lab 03 (Architecture)
04. Autonomy Lab 04 (Autonomy)
05. Safety Lab 05 (Human-in-the-Loop)
02. Prompting (SOP) Lab 06 (Incident)
06. RAG Lab 07 (RAG)
07. Multi-Agent Lab 08 (Multi-Agent)
09. Agent Anatomy Lab 01 (Basics), Lab 09 (Context Optimization)
10. Planning and Workflow Patterns Lab 10 (Planning & Workflow)
11. State Management Lab 10 (Planning & Workflow) — partially
12. Agent Memory Systems, 13. Context Engineering Lab 11 (Memory & Context Engineering)
18. Tool Protocols and Tool Servers Lab 12 (Tool Server Protocol)
17. Security and Governance Lab 13 (Agent Security Hardening) — Optional
22. Prompt and Program Management Lab 01 (Basics) — partially
23. Evals in CI/CD Lab 14 (Evals in CI) — Optional

📖 How to Use This Textbook

  1. Read sequentially — each chapter builds on previous ones
  2. Practice alongside reading — complete the corresponding laboratory assignment after each chapter
  3. Use as a reference — return to relevant sections when working on projects
  4. Study examples — each chapter includes examples from different domains (DevOps, Support, Data, Security, Product)
  5. Complete exercises — mini-exercises in each chapter help reinforce the material
  6. Check your understanding — use checklists for self-assessment

Happy Learning! 🚀