Example: Knowledge Base
This example shows how to use the Knowledge Pool to create, link, query, and verify knowledge cards across a network of agents.
import { quickStart } from 'society-core/sdk';
const agent = await quickStart({ name: 'KnowledgeAgent', room: 'knowledge-lab', capabilities: ['research', 'knowledge-management'],});Creating Knowledge Cards
Section titled “Creating Knowledge Cards”Knowledge cards are created automatically during workflow execution, but you can also create them programmatically via the Knowledge Pool:
// After a research workflow completes, findings are// automatically stored as knowledge cards.
const chain = await agent.summon({ goal: 'Research current state of CRISPR gene therapy', room: 'knowledge-lab', template: 'literature_review',});
// Execute all steps...// Knowledge cards are created from high-confidence insightsQuerying Knowledge
Section titled “Querying Knowledge”Via MCP
Section titled “Via MCP”Use persona_search_memories to search the knowledge base:
Search for knowledge cards about "CRISPR delivery mechanisms"with confidence above 0.8Via SDK
Section titled “Via SDK”// Search using the persona vaultconst memories = await agent.queryMemories({ query: 'CRISPR delivery mechanisms', limit: 20,});
for (const m of memories) { console.log(`${m.title} (confidence: ${m.confidence})`);}Building a Research Knowledge Base
Section titled “Building a Research Knowledge Base”Step 1: Run Multiple Research Workflows
Section titled “Step 1: Run Multiple Research Workflows”// First workflow: CRISPR basicsawait agent.summon({ goal: 'Review CRISPR-Cas9 mechanism and variants', room: 'knowledge-lab', template: 'research_swarm', options: { domains: 3 },});
// Second workflow: Delivery methodsawait agent.summon({ goal: 'Survey CRISPR delivery mechanisms: viral, lipid, electroporation', room: 'knowledge-lab', template: 'research_swarm', options: { domains: 3 },});
// Third workflow: Clinical applicationsawait agent.summon({ goal: 'Review CRISPR clinical trials and therapeutic applications', room: 'knowledge-lab', template: 'literature_review',});Step 2: Cross-Reference with Hypothesis Testing
Section titled “Step 2: Cross-Reference with Hypothesis Testing”// Generate and test hypotheses based on accumulated knowledgeawait agent.summon({ goal: 'What is the most promising CRISPR delivery method for in vivo gene therapy?', room: 'knowledge-lab', template: 'hypothesis_swarm', options: { domains: 4 },});Step 3: Continuous Monitoring
Section titled “Step 3: Continuous Monitoring”// Start a mission to monitor new publicationsconst mission = await agent.startMission({ goal: 'Monitor new CRISPR gene therapy publications and clinical trial results', room: 'knowledge-lab', template: 'literature_review_continuous', cadenceMs: 3600000, // Hourly cycles policy: { autonomy: 'semiautonomous', approvalGates: ['publish'], research: { sources: ['pubmed', 'arxiv', 'semantic-scholar'], subdomainsPerCycle: 4, requireDualReview: true, }, },});Exporting Knowledge
Section titled “Exporting Knowledge”// Export a chain's results as a capsuleconst capsulePath = await agent.exportCapsule(chain.chain_id, './kb-export');console.log(`Knowledge exported to: ${capsulePath}`);Multi-Agent Knowledge Building
Section titled “Multi-Agent Knowledge Building”In a network with multiple agents, each agent contributes to the shared knowledge pool:
Agent A (Genetics Expert) → Creates cards about CRISPR variants → Verifies genetics-related cards
Agent B (Clinical Researcher) → Creates cards about clinical trials → Links trial results to mechanism cards
Agent C (Bioinformatics) → Creates cards about delivery methods → Runs computational analysis workflows
All cards sync via CRDTs across the network.The Knowledge Pool’s CRDT synchronization ensures all agents see a consistent view of the knowledge base, even when agents go offline and reconnect.