Day 4: Agent Tools & Best Practices

Connecting AI to Reality

The “Brain in a Jar” Problem

The Isolated Genius

  • Imagine the world’s smartest physicist.
  • Locked in a soundproof room.
  • With no hands.
  • And no memory of anything that happened 5 minutes ago.

The Goal

AI App Integration

AI App Integration

Part 1: Spatial Connection (MCP)

The “Integration Tax”

The M \times N problem.

The \(M \times N\) problem.
  • Different servers specify different interfaces.
  • Clients have to implement their own tools for every interface.

Enter MCP: The “USB-C” for AI

The MCP solution to the M \times N problem.

The MCP solution to the \(M \times N\) problem.
  • MCP servers define their interfaces once in a standardized way for tool-aware LLMs to use.
  • MCP clients can then use these servers as tools without having to implement the interface themselves.

How it Works: The Invisible Wire

The Invisible Wire

The Invisible Wire
  1. Host: The App (e.g., Cursor, Python Script).
  2. Client: The “Driver” that speaks MCP.
  3. Server: The “App” that has the data (e.g., GitHub, Postgres).

Restaurant Analogy

The Restaurant Analogy

The Restaurant Analogy

Part 2: Temporal Connection (LRO)

The “Goldfish Memory” Problem

The “Goldfish Memory” Problem

The “Goldfish Memory” Problem

Long-Running Operations (LRO)

LRO Pattern

LRO Pattern
  1. Invoke: Start the task.
  2. Pause: Wait for external input (Human-in-the-Loop).
  3. Resume: Continue exactly where you left off.

The Solution: Resumability

  • The App Wrapper: A container that saves state to a database.
  • The Invocation ID: The unique “Ticket Number” for that specific task.

Visualizing the Loop

A circular workflow diagram. Arrow 1: Agent pauses. Arrow 2: State saved to DB. Arrow 3: Human clicks Approve. Arrow 4: Agent wakes up and finishes task.

A circular workflow diagram. Arrow 1: Agent pauses. Arrow 2: State saved to DB. Arrow 3: Human clicks Approve. Arrow 4: Agent wakes up and finishes task.
  • The Agent doesn’t “wait” in active memory.
  • It “persists” to disk.
  • This creates Safe, Asynchronous Autonomy.

Summary

The Complete Agent

  • LLM: Think & Use Tools
  • Spatial Connection:
    • MCP Host: The application that the agent is running in.
    • MCP Client: The agent that is using the MCP tools.
    • MCP Server: The server that is providing the MCP tools.
  • Temporal Connection:
    • HIL (Human-in-the-Loop): Pause & Resume
    • LRO (Long-Running Operations): Continue where it left off.