Agentic-Memory: Agent for Claude Code

.opencode/agents/kg-engineer.md

kg-engineer is an agent for Claude Code, OpenCode from ArkaAiAdmin/Agentic-Memory. It costs 21 tokens per session (2,272 once invoked), scanned A, original, Apache-2.0.

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 for Claude CodeOpenCode

Written for OpenCode and Claude Code: installed under .opencode/, but also a Claude Code subagent (agents/*.md). Also seen: mentions subagents.

This is ArkaAiAdmin/Agentic-Memory's own configuration. It tells Claude Code and OpenCode how to work on Agentic-Memory itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything Agentic-Memory configures →

Reuse

Borrowing it

Nothing to install: this file belongs to ArkaAiAdmin/Agentic-Memory. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/ArkaAiAdmin/Agentic-Memory/main/.opencode/agents/kg-engineer.md
Clone the repo
git clone --depth 1 https://github.com/ArkaAiAdmin/Agentic-Memory

Made for: Claude Code, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for kg-engineer

README.md
[![agentmods](https://agentmods.dev/badge/agents/arkaaiadmin/agentic-memory/kg-engineer/github.svg)](https://agentmods.dev/agents/arkaaiadmin/agentic-memory/kg-engineer)
Your own site
<a href="https://agentmods.dev/agents/arkaaiadmin/agentic-memory/kg-engineer"><img src="https://agentmods.dev/badge/agents/arkaaiadmin/agentic-memory/kg-engineer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for kg-engineer

Your own site · 80×15
<a href="https://agentmods.dev/agents/arkaaiadmin/agentic-memory/kg-engineer"><img src="https://agentmods.dev/badge/agents/arkaaiadmin/agentic-memory/kg-engineer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00021 $0.02272
Opus 5.5 $0.00008 $0.00909
Sonnet 5.5 $0.00004 $0.00454
Haiku 4.5 $0.00002 $0.00227

Measured 1mo ago against content hash 9b259cf50423, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo ago.

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. 1mo ago 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 1mo ago), licensed Apache-2.0. It adds 21 tokens to every session and 2,272 once invoked, about $0.0001 per session on Opus 5.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.