Knowledge Tools
Give your agents persistent memory with store, query, and delete operations.
Knowledge tools let your agents store and retrieve information that persists across runs. Store documents, FAQs, or any text, then query it naturally. The system automatically finds relevant content based on meaning, not just keywords.
Namespaces let you organize knowledge into categories (e.g., "policies", "products", "faq"). Entry IDs are unique within a namespace.
You can view, search, and manage all stored knowledge from the Knowledge page in your project dashboard.
query_knowledge
Search the knowledge base. Finds the most relevant content based on meaning, not just exact keywords.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | string | required | The search query. Be specific for best results |
| namespace | string? | null | Filter results to a specific namespace |
| min_score | float | 0.7 | Minimum relevance score (0.0 to 1.0) |
| max_results | int | 3 | Maximum number of results to return |
Return Value
Returns matching results with: content, entry_id, score (relevance 0-1), namespace
Examples
# Simple query
result = await query_knowledge("What is the refund policy?")
# Results contain matching content with relevance scores
for item in result["results"]:
print(f"[{item['score']:.0%}] {item['content'][:100]}...")# Filter by namespace
result = await query_knowledge(
query="How do I reset my password?",
namespace="support"
)
# Adjust score threshold and result count
result = await query_knowledge(
query="pricing information",
min_score=0.5, # Lower threshold = more results
max_results=10 # Return up to 10 results
)store_knowledge
Add new information to the knowledge base. Content is automatically processed and made searchable.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| content | string | required | The text content to store (any length) |
| entry_id | string? | auto | Custom ID for the entry (UUID generated if omitted) |
| namespace | string? | null | Category for organizing knowledge |
| metadata | dict? | null | Additional key-value data to store |
Return Value
Returns: entry_id, success, job_id. Storage is asynchronous. Returns immediately while content is processed in the background.
Examples
# Simple store (auto-generated ID)
result = await store_knowledge(
content="The company refund policy allows returns within 30 days."
)
# Returns: {"entry_id": "abc123...", "success": true}# Store with custom ID for later updates
result = await store_knowledge(
content="Q1 sales target is $1M with focus on enterprise.",
entry_id="q1-sales-target",
namespace="planning",
metadata={"quarter": "Q1", "year": "2024"}
)
# Store user preferences
result = await store_knowledge(
content="User prefers dark mode and metric units.",
entry_id="user-preferences",
namespace="user_data"
)delete_knowledge
Remove entries from the knowledge base by their entry ID. Useful for keeping the knowledge base clean and up-to-date.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| entry_id | string | required | The ID of the entry to delete |
| namespace | string? | null | Namespace to scope the deletion |
Return Value
Returns: ok (success), deleted_count. Entry IDs are unique per namespace. Specify namespace if the ID exists in multiple.
Examples
# Delete by entry_id
result = await delete_knowledge(entry_id="old-product-info")
# Delete from specific namespace
result = await delete_knowledge(
entry_id="q1-sales-target",
namespace="planning"
)Complete Agent Example
# agents/knowledge-agent.yaml
version: "1.0"
name: knowledge-agent
model: gemini/gemini-2.5-pro
description: "Agent with persistent memory"
system_prompt: |
You are an assistant with access to a knowledge base.
Always search the knowledge base first before answering.
tools:
- query_knowledge
- store_knowledge
- delete_knowledgeBest Practices
- Use descriptive entry_ids for easy updates
- Organize with namespaces (policies, products, faq)
- Be specific in queries for better results
- Clean up old entries regularly
Tips
- Query before answering: check knowledge base first
- Store structured content with clear headings
- Use metadata for dates, versions, categories
- Test queries in the Knowledge dashboard page