kg-engineer

A coding-agent role for organizing knowledge as a graph of entities, facts, relationships, and time-based changes.

In plain words
What is it for?
It is for exploring and querying a knowledge graph, searching stored facts, checking information as of a past date, and resolving contradictions.
Why use it?
It helps find connected information, identify duplicate facts, and detect when new knowledge conflicts with older notes.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/arkaaiadmin/agentic-memory/kg-engineer
Clone the repo
git clone --depth 1 https://github.com/ArkaAiAdmin/Agentic-Memory
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,272 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00021 $0.02272
Opus 5 $0.00010 $0.01136
Sonnet 5 $0.00004 $0.00454
Haiku 4.5 $0.00002 $0.00227

Measured yesterday against content hash 9b259cf50423, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

kg-engineer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.opencode/agents/kg-engineer.md · 176 lines

How it starts

The opening of the file, as written. The whole thing — 176 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a knowledge graph engineer for the agentic-memory system.

MCP entry points

# Graph exploration
memory_graph(query="<topic>", action="explore")
memory_graph(action="traverse", start="<entity_id>", max_depth=2)
memory_graph(action="shortest_path", source="<a>", target="<b>")
memory_graph(action="stats")

# KG fact search
memory_search(query="<query>", mode="facts", belief_status="active")
memory_search(query="<query>", mode="graph")

# Maintenance
memory_maintenance(operation="detect_contradictions")
memory_maintenance(operation="dedup")
memory_maintenance(operation="temporal_query", as_of="2026-03-15")

When a KG-resolution lesson you'd save contradicts a prior note, supersede it rather than leaving two conflicting memories: memory_note(note_id, action="supersede", rationale="...") — writes to memory_revision_log and retires the stale note. (Self-editing also runs automatically on every memory_save; verify extracted skills with memory_list_skills, now a CORE tool.)

Key files

kg/ directory

File Purpose Key functions
kg/graph_analytics.py PageRank + Betweenness centrality compute_pagerank(damping=0.85, max_iters=100), compute_betweenness() (Brandes O(V*(V+E))), update_graph_analytics(), update_betweenness()
kg/graph_communities.py Community detection connected_components() (iterative BFS), louvain_communities(resolution=1.0, max_phases=20), write_community_ids()
kg/temporal_resolver.py Temporal contradiction resolution resolve_temporal_contradiction(): Phase 1 closes old fact's valid_to, Phase 1b invalidates KG edges, Phase 2 propagates temporal scoping (capped at 10 entities)
kg/contradiction_detector.py Contradiction detection detect_contradictions() (phrase-based, 11 NEGATION_PAIRS), detect_contradictions_semantic() (embedding-based, 150+ TECHNICAL_ANTONYMS, threshold 0.65/0.78)
kg/contradiction_resolver.py Auto-resolution auto_resolve_contradiction_pair(): 4 strategies (supersede_b_with_a, supersede_a_with_b, merge, keep_both). Gated by MEMORY_CONTRADICTION_AUTO_RESOLVE_LLM=1
kg/kg_dedup.py Entity deduplication dedup_entities() (exact: group by name+type, keep highest-id, redirect edges), compute_semantic_merge_candidates(threshold=0.92), merge_entities()
kg/kg_traversal.py Graph traversal find_shortest_path(max_depth=5) (recursive CTE BFS), find_neighbors(direction, relation_types), traverse_graph() (pattern-matching with N joins)
kg/kg_crdt.py CRDT merge 2P-Set entity CRDT, add-only edge CRDT, version vectors, entity_dedup_via_crdt(), project_crdt_to_entities()

Read the full file on GitHub · 176 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 176 lines · 21 tokens per session scan A 9b259cf50423

Subscribe to this mod's changes

kg-engineer is an agent published in the GitHub repository ArkaAiAdmin/Agentic-Memory (0 stars, last pushed yesterday), licensed Apache-2.0. It adds 21 tokens to every session and 2,272 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens