Skip to main content

Overview

This guide covers advanced best practices for creating knowledge agents that are powerful, reliable, and delightful to use. These techniques come from real-world usage and help you avoid common pitfalls.

Prompt Engineering Best Practices

Write for AI, Not Humans

System instructions should be explicit and structured, not conversational. Don’t:
Do:
Why: AI models follow explicit instructions better than vague guidance.

Be Specific About Tool Usage

Tell the AI exactly when and how to use each tool. Vague (Bad):
Specific (Good):
Why: Specificity reduces guesswork and increases reliability.

Use Examples in System Instructions

Show the agent what good looks like. Without Examples:
With Examples:
Why: Examples create consistency and quality.

Define Boundaries Clearly

Tell the agent what NOT to do is as important as what to do. Good boundaries:
Why: Prevents the agent from hallucinating or overstepping.

Iterative Prompting Strategy

Build your system instructions incrementally: Day 1: Basic role
Day 2: Add workflow
Day 3: Add output formatting
Day 4: Add error handling
Why: Gradual refinement based on real usage beats trying to write perfect prompts upfront.

Knowledge Base Optimization

Chunk Your Knowledge Strategically

Poor knowledge structure:
  • One massive 100-page PDF with everything mixed together
  • Lots of irrelevant content (legal boilerplate, footers, headers)
Good knowledge structure:
  • Separate documents by topic: “Product Features.pdf”, “Pricing.pdf”, “API Docs.pdf”
  • Remove boilerplate and navigation text
  • Use clear headings and sections
  • Each document focused on one topic area
Why: Better chunks = better retrieval = more accurate responses.

Use Markdown Formatting in Knowledge

When creating knowledge documents, use structure: Poorly formatted:
Well formatted:
Why: Structured content is easier for the AI to parse and retrieve accurately.

Name Files Descriptively

Bad file names:
  • “Document1.pdf”
  • “Final_v2_FINAL.docx”
  • “Untitled.pdf”
Good file names:
  • “[POLICY] Refund and Return Policy.pdf”
  • “[GUIDE] API Authentication Guide.pdf”
  • “[FAQ] Common Customer Questions.pdf”
Why: File names provide context for retrieval.

Keep Knowledge Current

Weekly:
  • Check if any major facts changed
  • Update URLs that may have refreshed content
Monthly:
  • Review all knowledge for accuracy
  • Remove outdated information
  • Add new relevant content
Quarterly:
  • Audit entire knowledge base
  • Reorganize if needed
  • Test retrieval quality
Why: Stale knowledge leads to incorrect responses.

Quality Metrics for Knowledge

Good knowledge base:
  • 80%+ of user questions can be answered from knowledge
  • Responses cite relevant, accurate sources
  • Knowledge is current (updated within 3 months)
  • Focused on your domain (minimal irrelevant content)
Poor knowledge base:
  • Agent frequently says “I don’t have information about that”
  • Cites wrong or irrelevant sources
  • Information is outdated
  • Too much noise (agent retrieves irrelevant chunks)

Tool Orchestration Patterns

Start with 1-2 Tools, Scale Gradually

Phase 1: Single tool
Phase 2: Add complementary tool
Phase 3: Add output tool
Why: Testing sequentially isolates issues. Adding 10 tools at once makes debugging impossible.

Design Tool Chains

Think about natural sequences: Research Chain:
System instructions:
Sales Chain:
System instructions:
Why: Designed chains create reliable, repeatable workflows.

Add Confirmation Gates

For sensitive or irreversible actions, add approval steps: Pattern:
Implementation:
Why: Prevents unintended actions and builds user trust.

Handle Tool Failures Gracefully

Bad error handling:
Good error handling:
Why: Resilient agents maintain momentum even when tools fail.

Testing Strategies

The 3-Phase Testing Approach

Phase 1: Unit testing (Individual capabilities)
Phase 2: Integration testing (Tool combinations)
Phase 3: User acceptance testing (Real scenarios)

Build a Test Suite

Create a document with standard test cases: Example test suite:
Run through this suite:
  • After every major change
  • Before launching publicly
  • Weekly for public agents

A/B Test System Instructions

For public agents with traffic, test variations: Create two versions:
Run both for a week, then:
  • Review conversations from each
  • Which version led to better outcomes?
  • Which had fewer errors?
  • Which had better user engagement?
Example A/B test:

Performance Optimization

Response Speed

Slow agents are frustrating. Optimize for speed: Knowledge base optimization:
  • Don’t upload hundreds of documents (50-100 focused docs is plenty)
  • Remove duplicate/overlapping content
  • Keep individual documents under 25MB
Tool optimization:
  • Ensure workflow agents complete quickly (under 30 seconds ideal)
  • Use async operations when possible
  • Add timeout handling
Prompt optimization:
  • Shorter system instructions = faster processing
  • Remove unnecessary examples
  • Focus on essential guidance

Reduce Hallucinations

System instruction pattern:
Why: Explicit anti-hallucination instructions reduce confident but wrong answers.

Token Efficiency

Long conversations can hit token limits: In system instructions:
Why: Efficient token usage extends conversation length before context limits.

User Experience Design

Progressive Disclosure

Don’t overwhelm users with all capabilities at once: Welcome message progression:
Why: Gradual exposure improves onboarding and reduces cognitive load.

Conversation Pacing

Too fast:
Good pacing:
Why: Pacing gives users control and prevents information overload.

Personality Consistency

Choose a tone and stick to it: Professional:
Friendly:
Technical:
Why: Consistent personality builds trust and feels more professional.

Error Recovery

Good error recovery pattern:
Why: Users forgive errors if handled well.

Security & Privacy

Public Agent Considerations

If your agent is public, assume anyone might use it: Don’t:
  • Give it access to sensitive integrations (your email, internal CRM)
  • Upload confidential knowledge
  • Enable destructive actions
  • Store API keys in knowledge base
Do:
  • Use read-only integrations when possible
  • Curate knowledge for public consumption
  • Add strong confirmation gates for any writes
  • Review conversations regularly for misuse

Sensitive Data Handling

System instructions for sensitive scenarios:

Rate Limiting User Actions

For agents that call expensive or limited APIs: System instructions:
Why: Prevents abuse and runaway costs.

Maintenance & Iteration

The Weekly Review

Spend 30 minutes weekly reviewing your agent: What to check:
Make 1-2 improvements based on what you find.

Version Control for Prompts

Keep a changelog of system instruction changes: Example:
Why: You can roll back if a change makes things worse.

Feedback Loops

Create mechanisms to gather feedback: In system instructions:
Via shared conversations:
  • Ask early users to share conversations
  • Review what worked and what didn’t
  • Implement improvements

Common Pitfalls & Solutions

Problem: Agent writes paragraphs when users want quick answersSolution: Add to system instructions:
Problem: You enabled tools but agent just talksSolution:
  1. Check tools are actually enabled (Action Agents tab)
  2. Add explicit tool instructions to system prompt
  3. Test with direct requests: “Use [tool name] to…”
  4. Verify tool names are clear
Problem: Agent doesn’t use uploaded knowledgeSolution:
  1. Verify files finished processing
  2. Ask directly: “What do you know about [topic from knowledge]?”
  3. Check knowledge is well-structured with headings
  4. Remove duplicate/conflicting content
  5. Add to system instructions: “Always search knowledge base first”
Problem: Agent acts differently each timeSolution:
  • AI is probabilistic by nature (some variation is normal)
  • Reduce variation by being MORE specific in system instructions
  • Use examples to show exact format you want
  • Test the same query 5 times - if wildly different, prompt needs work
Problem: Users ask for things agent can’t doSolution:
  1. Improve welcome message clarity
  2. Better sample questions showing what agent CAN do
  3. Add to system instructions: “If asked about [outside scope], say: ‘I specialize in [your domain]. For [their request], try [alternative].”
Problem: Multi-tool workflows fail midwaySolution:
  1. Test each tool individually first
  2. Add error handling to system instructions
  3. Design tools to be independent (one tool failure doesn’t break everything)
  4. Add checkpoints: After each tool, summarize what you have before calling next

Advanced Patterns

The Expert Escalation Pattern

Use case: Tiered support, specialized domains

The Learning Agent Pattern

Use case: Continuous improvement, user research

The Collaborative Builder Pattern

Use case: Content creation, design work, strategic planning

Metrics for Success

Track these to measure your agent’s effectiveness: Qualitative:
  • Are conversations achieving user goals?
  • Do users return for multiple conversations?
  • Are shared conversations examples of success?
Quantitative:
  • Average conversation length (too short = not useful, too long = struggling)
  • Tool call success rate (should be >90%)
  • Knowledge retrieval frequency (are you using knowledge effectively?)
User Feedback:
  • Explicit positive feedback
  • Feature requests
  • Bug reports
Ideal Knowledge Agent:
  • Conversations: 5-15 messages to complete a task
  • Tool success: 95%+ successful tool calls
  • Knowledge usage: Cites knowledge in 70%+ of responses
  • User satisfaction: Repeat usage, positive shared examples

Next Steps

You now have advanced techniques for building exceptional knowledge agents:

Troubleshooting

Solve specific issues and optimize performance

Configuration

Apply best practices to your system instructions

Tools Integration

Implement advanced tool orchestration patterns

Knowledge Base

Optimize your knowledge for better retrieval
Remember: Building great knowledge agents is iterative. Start simple, launch quickly, learn from real usage, and continuously improve. The best agents evolve over time based on user feedback and measured outcomes.