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:Be Specific About Tool Usage
Tell the AI exactly when and how to use each tool. Vague (Bad):Use Examples in System Instructions
Show the agent what good looks like. Without Examples:Define Boundaries Clearly
Tell the agent what NOT to do is as important as what to do. Good boundaries:Iterative Prompting Strategy
Build your system instructions incrementally: Day 1: Basic roleKnowledge 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)
- 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
Use Markdown Formatting in Knowledge
When creating knowledge documents, use structure: Poorly formatted:Name Files Descriptively
Bad file names:- “Document1.pdf”
- “Final_v2_FINAL.docx”
- “Untitled.pdf”
- “[POLICY] Refund and Return Policy.pdf”
- “[GUIDE] API Authentication Guide.pdf”
- “[FAQ] Common Customer Questions.pdf”
Keep Knowledge Current
Weekly:- Check if any major facts changed
- Update URLs that may have refreshed content
- Review all knowledge for accuracy
- Remove outdated information
- Add new relevant content
- Audit entire knowledge base
- Reorganize if needed
- Test retrieval quality
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)
- 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 toolDesign Tool Chains
Think about natural sequences: Research Chain:Add Confirmation Gates
For sensitive or irreversible actions, add approval steps: Pattern:Handle Tool Failures Gracefully
Bad error handling:Testing Strategies
The 3-Phase Testing Approach
Phase 1: Unit testing (Individual capabilities)Build a Test Suite
Create a document with standard test cases: Example test 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:- Review conversations from each
- Which version led to better outcomes?
- Which had fewer errors?
- Which had better user engagement?
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
- Ensure workflow agents complete quickly (under 30 seconds ideal)
- Use async operations when possible
- Add timeout handling
- Shorter system instructions = faster processing
- Remove unnecessary examples
- Focus on essential guidance
Reduce Hallucinations
System instruction pattern:Token Efficiency
Long conversations can hit token limits: In system instructions:User Experience Design
Progressive Disclosure
Don’t overwhelm users with all capabilities at once: Welcome message progression:Conversation Pacing
Too fast:Personality Consistency
Choose a tone and stick to it: Professional:Error Recovery
Good error recovery pattern: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
- 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:Maintenance & Iteration
The Weekly Review
Spend 30 minutes weekly reviewing your agent: What to check:Version Control for Prompts
Keep a changelog of system instruction changes: Example:Feedback Loops
Create mechanisms to gather feedback: In system instructions:- Ask early users to share conversations
- Review what worked and what didn’t
- Implement improvements
Common Pitfalls & Solutions
Pitfall: Agent is too chatty
Pitfall: Agent is too chatty
Problem: Agent writes paragraphs when users want quick answersSolution:
Add to system instructions:
Pitfall: Agent doesn't use tools
Pitfall: Agent doesn't use tools
Problem: You enabled tools but agent just talksSolution:
- Check tools are actually enabled (Action Agents tab)
- Add explicit tool instructions to system prompt
- Test with direct requests: “Use [tool name] to…”
- Verify tool names are clear
Pitfall: Knowledge retrieval isn't working
Pitfall: Knowledge retrieval isn't working
Problem: Agent doesn’t use uploaded knowledgeSolution:
- Verify files finished processing
- Ask directly: “What do you know about [topic from knowledge]?”
- Check knowledge is well-structured with headings
- Remove duplicate/conflicting content
- Add to system instructions: “Always search knowledge base first”
Pitfall: Inconsistent behavior
Pitfall: Inconsistent behavior
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
Pitfall: Users confused about capabilities
Pitfall: Users confused about capabilities
Problem: Users ask for things agent can’t doSolution:
- Improve welcome message clarity
- Better sample questions showing what agent CAN do
- Add to system instructions: “If asked about [outside scope], say: ‘I specialize in [your domain]. For [their request], try [alternative].”
Pitfall: Tool chains breaking
Pitfall: Tool chains breaking
Problem: Multi-tool workflows fail midwaySolution:
- Test each tool individually first
- Add error handling to system instructions
- Design tools to be independent (one tool failure doesn’t break everything)
- Add checkpoints: After each tool, summarize what you have before calling next
Advanced Patterns
The Expert Escalation Pattern
The Learning Agent Pattern
The Collaborative Builder Pattern
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?
- 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?)
- Explicit positive feedback
- Feature requests
- Bug reports
- 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.

