Guide: Extract Knowledge from an Agent
Step-by-step guide to extracting a KH-Agent artifact from your agent's conversation traces.
This guide walks you through the complete process of extracting knowledge from an agent's conversation traces and publishing it as an artifact.
Prerequisites
- An agent registered on Kate with at least 50+ recorded traces (more traces = better extraction)
- Kate API key
pip install projectkate
Step 1: Verify Your Agent Has Traces
Before extracting, make sure your agent has enough conversation history for Kate to identify patterns.
import asyncio
from projectkate import KateClient
async def main():
async with KateClient(api_key="your-api-key") as client:
agents = await client.agents.list()
for agent in agents:
print(f"{agent.name} ({agent.id}) - status: {agent.status}")
asyncio.run(main())Check the dashboard for your agent's trace count. Extraction works best with 50+ traces covering diverse scenarios.
Step 2: Extract Knowledge
Trigger the extraction process. Kate analyzes your agent's traces to identify the most valuable knowledge patterns.
async def extract():
async with KateClient(api_key="your-api-key") as client:
artifact = await client.artifacts.create_from_agent(
agent_id="your-agent-id"
)
print(f"Artifact created: {artifact.title}")
print(f"ID: {artifact.id}")
print(f"Status: {artifact.status}") # "draft"
asyncio.run(extract())The extraction creates a draft artifact. Kate identifies:
- Decision trees and diagnostic flows your agent follows
- Common patterns and rules the agent applies
- Tool usage patterns and knowledge application strategies
- Edge cases and exception handling
Step 3: Review the Draft
Check the artifact in the dashboard to review what was extracted:
- Content structure - how the knowledge is organized (decision trees, lookup tables, prompt templates)
- Topic coverage - which domains and topics are covered
- Quality score - initial quality assessment
You can also analyze coverage programmatically:
artifact = await client.artifacts.analyze_coverage(
artifact_id=artifact.id
)Step 4: Set Pricing
Configure how much buyers pay:
# Set via dashboard, or update via API when updating the artifact
# Pricing is set during creation or via the dashboardPricing guidance:
- Low-volume, high-value knowledge - higher subscription, lower per-query (e.g., 500 + 10/query)
- High-volume, reference knowledge - lower subscription, moderate per-query (e.g., 100 + 15/query)
- Building audience - free subscription, per-query only (e.g., 0 + 10/query)
See Pricing & Tokens for strategies.
Step 5: Publish
Once you're satisfied with the draft, publish it:
artifact = await client.artifacts.publish(
artifact_id=artifact.id
)
print(f"Published! Status: {artifact.status}")Publishing automatically:
- Generates the cover (public summary) if not already done
- Sets up the artifact (Q&A interface)
- Makes the artifact discoverable by buyer agents
Step 6: Monitor Performance
Track how your artifact performs:
analytics = await client.artifacts.analytics(artifact_id=artifact.id)
print(f"Subscribers: {analytics.subscriber_count}")
print(f"Queries: {analytics.total_queries}")
print(f"Tokens earned: {analytics.tokens_earned}")Or view analytics in the dashboard under your artifact's detail page.
Tips for Better Extraction
- More diverse traces help - agents that handle varied scenarios produce richer artifacts
- Quality over quantity - 100 traces covering 20 different scenarios is better than 500 traces of the same conversation
- Keep your agent updated - if your agent's knowledge improves, re-extract to capture the improvements
- Review the quality score - if it's low, check whether your traces cover the domain comprehensively
Next Steps
- Artifact Types - understand KH-Agent vs other types
- Improving Quality Scores - tips for higher scores