Skip to main content

Overview

The OfficeFlow agent evolved through six versions, each addressing specific production issues discovered through testing and analysis. This progression demonstrates a realistic development cycle for production AI agents.
1

v0: Basic Implementation

Initial agent with no observability
2

v1: Add Tracing

LangSmith integration for debugging
3

v2: Fix Tool Descriptions

Improved schema discovery guidance
4

v3: Stock Communication Policy

Strategic inventory messaging
5

v4: RAG Implementation

Full document retrieval instead of chunking
6

v5: Conciseness Directive

Reduced verbosity in responses

v0: The Baseline Agent

What It Does

The initial implementation includes:
  • Basic chat loop with conversation history
  • Two tools: query_database and search_knowledge_base
  • RAG using text chunking and embeddings
  • System prompt with persona and guidelines

Key Characteristics

The Problem

No observability. When the agent behaves unexpectedly, there’s no way to:
  • See what tool calls were made
  • Inspect the LLM’s reasoning
  • Debug multi-step interactions
  • Analyze patterns across conversations

v1: Adding Tracing

What Changed

Integration with LangSmith for complete observability:

Benefits

Complete Visibility

Every LLM call, tool invocation, and intermediate step is recorded

Easy Debugging

Click through traces in LangSmith UI to see exactly what happened

Thread Tracking

Associate multiple interactions with the same conversation

Performance Analysis

Measure latency, token usage, and cost per interaction

v2: Enhanced Tool Descriptions

The Problem

In production, the agent would sometimes fail to query the database correctly because it didn’t know the schema. It would make assumptions or generate invalid SQL.

The Fix

Added explicit schema discovery instructions to the tool description:

Key Insight

Tool descriptions are critical prompt engineering real estate. The LLM reads them every time it decides whether to use a tool and how to format arguments.
By adding step-by-step instructions directly in the tool description, we ensure the agent follows the correct discovery process without requiring system prompt changes.

v3: Stock Quantity Policy

The Problem

The agent was revealing exact stock quantities to customers: “We have 47 units in stock.” This:
  • Exposed competitive information
  • Gave customers leverage to negotiate or wait
  • Didn’t create urgency for low-stock items

The Solution

Added a comprehensive stock communication policy to the system prompt:

Business Impact

Competitors can’t gauge inventory levels by probing the agent
Low stock items use language that encourages faster purchasing decisions
Maintains helpful tone while implementing business strategy

v4: RAG Improvements

The Problem

v0-v3 used text chunking for the knowledge base:
  • Documents split into 200-character chunks with 20-character overlap
  • Agent retrieved 2 most relevant chunks
  • Often got incomplete information from split documents
  • Context boundaries could split important related information

The Fix

Switched to full document retrieval:

Benefits

Complete Context

The agent sees entire policy documents, not fragments

No Boundary Issues

Related information stays together

Better Answers

Can synthesize complete policies rather than partial snippets

Cache Invalidation

Automatically regenerates embeddings when docs change

Trade-offs

This approach works well for OfficeFlow because:
  • Knowledge base documents are relatively small (< 2000 tokens each)
  • The LLM context window can handle 2 full documents comfortably
  • Policy information is best understood in complete form
For larger documents or massive knowledge bases, chunking strategies may still be necessary.

v5: Conciseness Directive

The Problem

During evaluation, the agent’s responses were often too verbose:
  • Repeated information unnecessarily
  • Used filler phrases like “I’d be more than happy to help you with that”
  • Explained things that customers already understood
  • Took 3 sentences when 1 would suffice

The Solution

Added an explicit conciseness directive to the system prompt:
Also updated example interactions to model concise responses:

Measurement

This change can be quantitatively evaluated using:
  • Token count reduction in responses
  • Character/word count metrics
  • Pairwise evaluation (v4 vs v5) with human or LLM judges
  • Customer satisfaction scores
See Evaluating Conciseness for implementation details.

Version Comparison

Running Different Versions

Key Takeaways

Iterate Based on Evidence

Each version addresses a real issue discovered through testing or production use

Observability First

Adding tracing (v1) enables all subsequent improvements

Tool Descriptions Matter

They’re read on every tool use - make them comprehensive

Business Logic in Prompts

The stock policy (v3) shows how to encode business rules

RAG is Nuanced

Chunking vs full documents depends on your use case

Measure Everything

Conciseness improvements (v5) need evaluation to validate

Next Steps

Analyzing Agent Behavior

Learn how to use LangSmith traces to debug and improve your agents