Skip to main content

Introduction

The OfficeFlow agent is a customer support assistant named Emma, designed to help customers of OfficeFlow Supply Co., a paper and office supplies distributor serving small-to-medium businesses across North America. This agent serves as the primary example throughout the Building Reliable Agents course, demonstrating how to build, evaluate, and improve production-ready AI agents.

Agent Persona

Emma is a customer support specialist with 3 years at OfficeFlow, known for being:
  • Helpful and efficient - Focuses on solving customer problems quickly
  • Genuinely caring - Treats every interaction as an opportunity to build trust
  • Knowledgeable - Has access to product databases and company knowledge bases
  • Human - Uses natural language, shows empathy, and avoids robotic responses

Core Capabilities

The agent can help with:
  • Answer questions about office supplies, paper products, writing instruments, organizational tools, and desk accessories
  • Provide detailed product specifications and details
  • Recommend products based on customer needs and budget
  • Check current stock levels in real-time
  • Help customers find available alternatives
  • Communicate availability using strategic language (e.g., “in stock” vs “running low”)
  • Search knowledge base for policy information
  • Answer questions about shipping, returns, ordering processes
  • Provide contact information for specialized departments

What the Agent Cannot Handle

Emma is designed with clear boundaries and will redirect customers to appropriate channels for:

Key Design Principles

1. Check Database First

The agent is instructed to always check the database first before asking clarifying questions. This creates a better user experience:
Customer: "Do you have any paper?"
Agent: "What type of paper are you looking for?"

2. Strategic Stock Communication

The agent never reveals exact stock quantities. Instead, it uses strategic language:
  • > 20 units: “In stock” or “Available”
  • 10-20 units: “In stock, but running low”
  • 5-9 units: “Only a few left in stock”
  • 1-4 units: “Very limited stock remaining”
  • 0 units: “Currently out of stock”
This protects competitive advantage while creating appropriate urgency.

3. Concise Communication

The agent prioritizes brevity:
  • Get straight to the answer
  • Avoid unnecessary filler or repetition
  • If something can be said in one sentence, don’t use three

Tools & Architecture

The agent has access to two primary tools:

query_database

Executes SQL queries against the inventory database for product information, stock levels, and pricing.

search_knowledge_base

Performs semantic search using embeddings to retrieve relevant policy documents and company information.

Technical Stack

  • LLM Provider: OpenAI (gpt-5-nano model)
  • Tracing: LangSmith for observability
  • Database: SQLite3 for product inventory
  • Embeddings: text-embedding-3-small for RAG
  • Vector Store: In-memory with NumPy

Agent Evolution

The OfficeFlow agent went through multiple iterations, each addressing specific production challenges:
  • v0: Basic implementation with no observability
  • v1: Added LangSmith tracing for debugging
  • v2: Enhanced tool descriptions to fix schema discovery
  • v3: Added stock quantity communication policy
  • v4: Implemented RAG with full document retrieval
  • v5: Added conciseness directive to reduce verbosity
Each version teaches important lessons about building reliable agents in production. See the Agent Versions page for detailed progression.

System Prompt Structure

The agent’s system prompt follows a clear structure:
  1. Role & Persona - Who Emma is and her background
  2. Capabilities - What she can help with
  3. Boundaries - What she cannot handle
  4. Communication Style - How to interact with customers
  5. Critical Instructions - Key behavioral guidelines (check database first, stock policy, etc.)
  6. Tools - Descriptions of available functions
  7. Examples - Sample interactions demonstrating expected behavior
This structure ensures the agent has clear context while maintaining appropriate boundaries.

Running the Agent

cd source/python/officeflow-agent
python agent_v5.py
The agent will:
  1. Load the knowledge base and generate/cache embeddings
  2. Start an interactive chat session
  3. Display the thread ID for tracing in LangSmith
  4. Accept user input until you type ‘quit’ or ‘exit’

Next Steps

Agent Versions

Explore the progressive improvements from v0 to v5

Analyzing Agents

Learn how to analyze agent behavior using traces

Build docs developers (and LLMs) love