Skip to content

Designing Autonomous AI Agents

For programmers who want to build production AI agents


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 handbook
  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. Expand capabilities:
  6. Dive deeper into architecture:
  7. 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?

    • Agent = LLM + Tools + Memory + Planning
    • LLM is the "brain" that makes decisions
    • Tools are the "hands" that perform actions
    • Memory is history and long-term storage
    • Planning is the ability to break down a task into steps
  2. 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
    

  3. Key points:

    • LLM doesn't execute code. It generates JSON with an execution request.
    • Runtime (your code) executes real Go functions.
    • LLM doesn't "remember" the past. It processes it in messages[], which Runtime collects.
    • Temperature = 0 for deterministic agent behavior.
  4. 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: "gpt-4o-mini",
        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
    }
    

  5. What to read next:

After Completing the Main Course

After studying chapters 1-16, proceed to:


Connection with laboratory assignments

Handbook 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

How to use this handbook

  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.