Skip to content

Multi-agent governance system capable of doing knowledge mining on NeuroWeb, initially focusing on supply chain dynamics. Forked from https://github.com/OriginTrail/dkg-node

License

Notifications You must be signed in to change notification settings

samartho4/AgentDKG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AgentDKG: Neuro-Symbolic Supply Chain Guardian

Completing the Knowledge Mining Lifecycle on OriginTrail DKG

Challenge DKG Edge Node Architecture

๐Ÿ† Built for "Scaling Trust in the Age of AI" Global Hackathon

Architecture โ€ข Demo โ€ข Installation โ€ข Documentation


๐ŸŽฏ The Problem

Current AI agents suffer from three critical limitations:

1. Ephemeral Memory โ€” Agents forget everything between sessions
2. No Provenance โ€” Reasoning cannot be verified or audited
3. Incomplete Knowledge Mining โ€” Existing DKG only does 50% of the cycle

OriginTrail's Knowledge Mining has 4 phases:

Discovery โ†’ Publishing โ†’ Enrichment โ†’ Learning
    โœ“           โœ“            โœ—            โœ—

AgentDKG completes this cycle.


๐Ÿ’ก Solution: Three-Layer Architecture

AgentDKG introduces a DeepAgents plugin that bridges neural reasoning with symbolic knowledge graphs, creating persistent, verifiable, self-improving AI agents.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        AGENT LAYER (Blue)                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Expo UI โ†’ MCP Server โ†’ DeepAgents Plugin                       โ”‚
โ”‚  โ”œโ”€ Main Orchestrator (reads /memories/instructions.md)         โ”‚
โ”‚  โ”œโ”€ Enrichment Subagent (writes community_note + triples)       โ”‚
โ”‚  โ””โ”€ Validation Subagent (computes trust, logs history)          โ”‚
โ”‚                                                                  โ”‚
โ”‚  Virtual Memory: /memories/                                      โ”‚
โ”‚  โ”œโ”€ instructions.md (self-improving)                            โ”‚
โ”‚  โ”œโ”€ knowledge/{domain}/community_note.md                        โ”‚
โ”‚  โ”œโ”€ knowledge/{domain}/triples.jsonld                           โ”‚
โ”‚  โ””โ”€ trust/history.jsonl                                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     KNOWLEDGE LAYER (Green)                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ctx.dkg Client โ†’ DKG Operations                                 โ”‚
โ”‚  โ”œโ”€ dkg_get (retrieve Knowledge Assets by UAL)                  โ”‚
โ”‚  โ””โ”€ dkg_create (publish JSON-LD to DKG)                         โ”‚
โ”‚                                                                  โ”‚
โ”‚  OriginTrail Network                                             โ”‚
โ”‚  โ””โ”€ Knowledge Assets โ†’ NeuroWeb โ†’ Polkadot                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      TRUST LAYER (Orange)                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  x402_trust_score โ†’ Trust Signals โ†’ Self Improving              โ”‚
โ”‚  โ””โ”€ Multi-factor scoring: diversity, recency, corroboration     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ—๏ธ Architecture Deep Dive

Layer 1: Agent Layer (Blue)

The Agent Layer implements a DeepAgents plugin with MCP (Model Context Protocol) integration, featuring specialized subagents with context isolation.

Component Description Key Innovation
MCP Server Exposes tools to LLM workflows via Model Context Protocol Standard DKG Node capability
Main Orchestrator Coordinates subagents, manages context window, handles tool calls Reads /memories/instructions.md at startup for self-improvement
Enrichment Subagent Discovers & cross-references facts Writes community_note.md + triples.jsonld
Validation Subagent Computes trust scores, validates knowledge Reads enrichment outputs, logs to history.jsonl
Virtual Memory Persistent file-based memory at /memories/ KEY INNOVATION: Cross-session learning

Subagent Architecture

// agent.ts - Subagent Definitions
const subagents = [
  {
    name: "knowledge_enrichment",
    tools: ["dkg_get", "internet_search", "write_file"],
    constraints: {
      dkg_get: { maxCalls: 1 },
      internet_search: { maxCalls: 3 }
    },
    outputs: [
      "/memories/knowledge/{domain}/community_note.md",
      "/memories/knowledge/{domain}/triples.jsonld"
    ]
  },
  {
    name: "knowledge_validation",
    tools: ["x402_trust_score", "read_file", "write_file"],
    constraints: {
      x402_trust_score: { maxCalls: 1 }
    },
    inputs: [
      "/memories/knowledge/{domain}/community_note.md",
      "/memories/knowledge/{domain}/triples.jsonld"
    ],
    outputs: [
      "/memories/trust/history.jsonld"
    ]
  }
];

Why Subagents?

  • Context Isolation: Each subagent has a focused context window
  • Token Efficiency: โ‰ค200 tokens/message budget per subagent
  • Specialized Tools: Enrichment gets search; Validation gets trust scoring
  • Auditable Workflow: Clear handoff via persistent files

Layer 2: Knowledge Layer (Green)

The Knowledge Layer leverages the OriginTrail DKG via the injected ctx.dkg client, providing verifiable, blockchain-anchored knowledge storage.

Tool Purpose Parameters
dkg_get Retrieve Knowledge Assets by UAL ual: string
dkg_create Publish JSON-LD to DKG content: JSON-LD, privacy: "private" | "public"

DKG Integration Example

// tools.ts - dkg_create implementation
export function makeDkgCreateTool(ctx: DkgContext) {
  return {
    name: "dkg_create",
    description: "Publish enriched knowledge as a Knowledge Asset on the DKG",
    schema: z.object({
      content: z.record(z.unknown()),
      privacy: z.enum(["private", "public"]).default("public")
    }),
    execute: async ({ content, privacy }) => {
      const result = await ctx.dkgClient.asset.create({
        public: content,
        private: {},
      }, {
        epochsNum: 2,
        maxNumberOfRetries: 3,
        frequency: 1,
        blockchain: {
          name: process.env.DKG_BLOCKCHAIN
        }
      });
      
      return {
        ual: result.UAL,
        status: "published",
        blockchain: process.env.DKG_BLOCKCHAIN
      };
    }
  };
}

JSON-LD Output Schema

{
  "@context": {
    "schema": "https://schema.org/",
    "dkg": "https://origintrail.io/ontology/",
    "trust": "https://x402.org/ontology/"
  },
  "@type": "dkg:CommunityNote",
  "schema:about": {
    "@type": "schema:Organization",
    "schema:name": "TSMC",
    "schema:identifier": "ual:otp:2043/0x..."
  },
  "dkg:enrichedBy": "AgentDKG/v1.0",
  "dkg:enrichmentDate": "2025-11-27T12:00:00Z",
  "trust:globalTrustScore": 0.87,
  "trust:trustSignals": [
    {
      "@type": "trust:X402Signal",
      "trust:source": "web_corroboration",
      "trust:confidence": 0.92
    }
  ],
  "schema:description": "TSMC governance analysis with cross-referenced sources..."
}

Layer 3: Trust Layer (Orange)

The Trust Layer implements x402-inspired trust scoring with self-improving logic that persists across sessions.

Component Function Output
x402_trust_score Computes trust based on source diversity, recency, corroboration { score: 0-1, signals: [...] }
Trust Signals Structured evidence for trust computation Logged to history.jsonl
Self Improving Analyzes historical scores to improve future assessments Updates instructions.md

Trust Scoring Algorithm

// tools.ts - x402_trust_score implementation
export function makeX402TrustScoreTool() {
  return {
    name: "x402_trust_score",
    schema: z.object({
      claim: z.string(),
      sources: z.array(z.object({
        url: z.string(),
        snippet: z.string(),
        reliability: z.enum(["high", "medium", "low"])
      }))
    }),
    execute: async ({ claim, sources }) => {
      // Multi-factor trust computation
      const factors = {
        sourceDiversity: computeSourceDiversity(sources),
        temporalRecency: computeRecencyScore(sources),
        crossCorroboration: computeCorroborationScore(claim, sources),
        domainAuthority: computeDomainAuthority(sources)
      };
      
      const globalScore = weightedAverage(factors, {
        sourceDiversity: 0.25,
        temporalRecency: 0.20,
        crossCorroboration: 0.35,
        domainAuthority: 0.20
      });
      
      return {
        kind: "x402_trust_signal",
        global_trust_score: globalScore,
        factors,
        qualitative: globalScore > 0.7 ? "high" : globalScore > 0.4 ? "medium" : "low",
        timestamp: new Date().toISOString()
      };
    }
  };
}

๐Ÿ”„ Knowledge Mining Workflow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                          USER QUERY                              โ”‚
โ”‚         "Analyze TSMC supply chain risks"                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    MCP SERVER (Port 9200)                        โ”‚
โ”‚                Tool: knowledge_miner_run                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      MAIN ORCHESTRATOR                           โ”‚
โ”‚  1. Reads /memories/instructions.md (self-improvement)           โ”‚
โ”‚  2. Delegates to subagents                                       โ”‚
โ”‚  3. Manages token budget (โ‰ค200 tokens/message)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚                    โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ENRICHMENT SUBAGENT โ”‚                  โ”‚ VALIDATION SUBAGENT โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค                  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ€ข dkg_get (1x)      โ”‚                  โ”‚ โ€ข read_file         โ”‚
โ”‚ โ€ข internet_search   โ”‚                  โ”‚ โ€ข x402_trust_score  โ”‚
โ”‚   (โ‰ค3x via Tavily)  โ”‚                  โ”‚   (1x)              โ”‚
โ”‚ โ€ข write_file        โ”‚                  โ”‚ โ€ข write_file        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚                                            โ”‚
        โ–ผ                                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   OUTPUT FILES      โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚    INPUT FILES      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค                  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ community_note.md   โ”‚ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚ community_note.md   โ”‚
โ”‚ triples.jsonld      โ”‚ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚ triples.jsonld      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                     โ”‚
                                                     โ–ผ
                                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                         โ”‚   TRUST OUTPUT      โ”‚
                                         โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
                                         โ”‚ history.jsonl       โ”‚
                                         โ”‚ (appended)          โ”‚
                                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                     โ”‚
                                                     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      MAIN ORCHESTRATOR                           โ”‚
โ”‚  โ€ข Reviews enrichment + validation outputs                       โ”‚
โ”‚  โ€ข Calls dkg_create to publish Knowledge Asset                   โ”‚
โ”‚  โ€ข Returns session summary + UAL                                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 DKG (NeuroWeb โ†’ Polkadot)                        โ”‚
โ”‚  โ€ข Knowledge Asset published with 2 epochs                       โ”‚
โ”‚  โ€ข 3 finalization confirmations                                  โ”‚
โ”‚  โ€ข Blockchain-anchored provenance                                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Key Innovations

1. Virtual Memory System (/memories/)

Unlike ephemeral chat agents, AgentDKG persists knowledge across sessions:

/memories/
โ”œโ”€โ”€ instructions.md              # Self-improving agent instructions
โ”œโ”€โ”€ knowledge/
โ”‚   โ”œโ”€โ”€ tsmc/
โ”‚   โ”‚   โ”œโ”€โ”€ community_note.md
โ”‚   โ”‚   โ””โ”€โ”€ triples.jsonld
โ”‚   โ””โ”€โ”€ intel/
โ”‚       โ”œโ”€โ”€ community_note.md
โ”‚       โ””โ”€โ”€ triples.jsonld
โ””โ”€โ”€ trust/
    โ””โ”€โ”€ history.jsonl            # Accumulated trust scores

Impact: The agent becomes smarter over time. Trust history informs future assessments.

2. Subagent Context Isolation

Each subagent operates with:

  • Isolated context window: No cross-contamination
  • Specialized tool access: Right tools for the right job
  • Token discipline: Strict budget prevents context overflow

3. Complete Knowledge Mining Cycle

Phase Existing DKG With AgentDKG
Discovery โœ… dkg_get โœ… Enhanced with web search
Publishing โœ… dkg_create โœ… With trust metadata
Enrichment โŒ Missing โœ… Cross-referencing, annotation
Learning โŒ Missing โœ… Self-improving instructions

4. Neuro-Symbolic Bridge

AgentDKG bridges:

  • Neural: LLM reasoning, natural language understanding
  • Symbolic: JSON-LD triples, DKG Knowledge Assets, verifiable provenance

๐Ÿ“ Project Structure

dkg-node/
โ”œโ”€โ”€ apps/
โ”‚   โ””โ”€โ”€ agent/                   # Expo UI (existing)
โ”‚       โ””โ”€โ”€ src/
โ”‚           โ””โ”€โ”€ components/
โ”‚               โ”œโ”€โ”€ ChatPage.tsx              # Main chat interface
โ”‚               โ”œโ”€โ”€ DeepAgentsPanel.tsx       # Real-time agent workspace
โ”‚               โ”œโ”€โ”€ KnowledgeMinerPanel.tsx
โ”‚               โ””โ”€โ”€ ThreadHistoryPanel.tsx
โ”‚
โ””โ”€โ”€ packages/
    โ””โ”€โ”€ plugin-deepagents-knowledge-miner/    # OUR CONTRIBUTION
        โ”œโ”€โ”€ src/
        โ”‚   โ”œโ”€โ”€ agent.ts         # DeepAgents orchestrator
        โ”‚   โ”œโ”€โ”€ tools.ts         # MCP tools (dkg_get, dkg_create, x402)
        โ”‚   โ””โ”€โ”€ index.ts         # Plugin registration
        โ”œโ”€โ”€ tests/
        โ”‚   โ”œโ”€โ”€ unit/
        โ”‚   โ””โ”€โ”€ integration/
        โ””โ”€โ”€ package.json

๐Ÿ”ง Installation & Setup

Prerequisites

  • Node.js โ‰ฅ 18.0
  • pnpm (recommended) or npm
  • DKG Edge Node access
  • Tavily API key (for web search)

Quick Start

# Clone the fork
git clone https://github.com/YOUR_USERNAME/dkg-node.git
cd dkg-node

# Install dependencies
pnpm install

# Configure environment
cp .env.example .env

# Edit .env with your credentials:
# - DKG_BLOCKCHAIN=otp:20430 (testnet)
# - DKG_OTNODE_URL=https://v6-pegasus-node-02.origin-trail.network:8900
# - DKG_PUBLISH_WALLET=your_private_key
# - TAVILY_API_KEY=your_tavily_key
# - LLM_PROVIDER=anthropic
# - LLM_MODEL=claude-sonnet-4-20250514

# Build
pnpm build

# Run development server
pnpm dev

Accessing the UI


๐ŸŽฎ Demo: Supply Chain Analysis

Example Query

"Analyze TSMC's governance structure and supply chain vulnerabilities for Q4 2025. 
Cross-reference with recent geopolitical developments."

Expected Agent Behavior

  1. Enrichment Subagent activates:

    • Calls dkg_get for existing TSMC Knowledge Assets
    • Performs internet_search via Tavily (up to 3 queries)
    • Writes community_note.md with analysis
    • Generates triples.jsonld with structured facts
  2. Validation Subagent activates:

    • Reads enrichment outputs
    • Calls x402_trust_score on key claims
    • Appends to history.jsonl
    • Updates community note with trust metadata
  3. Main Orchestrator publishes:

    • Calls dkg_create with enriched Knowledge Asset
    • Returns UAL and session summary

Sample Output

{
  "session_id": "km_1732712400_tsmc",
  "domain": "tsmc",
  "status": "complete",
  "outputs": {
    "community_note": "/memories/knowledge/tsmc/community_note.md",
    "triples": "/memories/knowledge/tsmc/triples.jsonld",
    "ual": "ual:otp:20430/0x7a8f...3b2c"
  },
  "trust": {
    "global_score": 0.87,
    "qualitative": "high",
    "signals_count": 4
  },
  "token_usage": {
    "enrichment": 1842,
    "validation": 956,
    "total": 2798
  }
}

๐Ÿ“š References


๐Ÿ“„ License

MIT License - See LICENSE for details.


AgentDKG: From Ephemeral Chat to Collective Intelligence on the Decentralized Knowledge Graph

Built for the "Scaling Trust in the Age of AI" Global Hackathon

About

Multi-agent governance system capable of doing knowledge mining on NeuroWeb, initially focusing on supply chain dynamics. Forked from https://github.com/OriginTrail/dkg-node

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published