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.
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.
Added explicit schema discovery instructions to the tool description:
Python
TypeScript
QUERY_DATABASE_TOOL = { "type": "function", "function": { "name": "query_database", "description": "SQL query to get information about our inventory.", "parameters": { "type": "object", "properties": { "query": { "type": "string", "description": """SQL query to execute against the inventory database.YOU DO NOT KNOW THE SCHEMA. ALWAYS discover it first:1. Query 'SELECT name FROM sqlite_master WHERE type="table"' to see available tables2. Use 'PRAGMA table_info(table_name)' to inspect columns for each table3. Only after understanding the schema, construct your search queries""" } }, "required": ["query"] } }}
const QUERY_DATABASE_TOOL = { type: "function" as const, function: { name: "query_database", description: "SQL query to get information about our inventory.", parameters: { type: "object", properties: { query: { type: "string", description: `SQL query to execute against the inventory database.YOU DO NOT KNOW THE SCHEMA. ALWAYS discover it first:1. Query 'SELECT name FROM sqlite_master WHERE type="table"' to see available tables2. Use 'PRAGMA table_info(table_name)' to inspect columns for each table3. Only after understanding the schema, construct your search queries`, }, }, required: ["query"], }, },};
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.
Added a comprehensive stock communication policy to the system prompt:
IMPORTANT - STOCK INFORMATION POLICY:When discussing product availability, NEVER reveal specific stock quantities or numbers to customers. Instead:- If quantity > 20: Say the item is "in stock" or "available"- If quantity 10-20: Say the item is "in stock, but running low" or "available, though inventory is limited" to create urgency- If quantity 5-9: Say "only a few left in stock" or "limited availability" to encourage quick action- If quantity 1-4: Say "very limited stock remaining" or "almost sold out"- If quantity 0: Say "currently out of stock" or "unavailable at the moment"This policy protects our competitive advantage and inventory management strategy while still helping customers make informed purchasing decisions.
Added an explicit conciseness directive to the system prompt:
CONCISENESS PRIORITY:Your responses should be brief and to the point. Avoid unnecessary filler, repetition, or overly elaborate explanations. Get straight to the answer. If you can say something in one sentence, don't use three. Customers appreciate quick, direct answers over lengthy responses.
Also updated example interactions to model concise responses:
Customer: "Do you have copy paper?"You: "Yes, we do! We carry several types of copy paper. Are you looking for standard 8.5x11 inch letter size, or do you need a specific weight or finish? I can check what we have in stock."
cd source/python/officeflow-agent# Run specific versionpython agent_v0.pypython agent_v1.pypython agent_v2.pypython agent_v3.pypython agent_v4.pypython agent_v5.py # Production version
cd source/ts/officeflow-agent# Run specific versionnpx tsx agent_v0.tsnpx tsx agent_v1.tsnpx tsx agent_v2.tsnpx tsx agent_v3.tsnpx tsx agent_v4.tsnpx tsx agent_v5.ts # Production version