Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Memgraph GraphRAG, AI Memory, and Agentic AI

Thilke uses Memgraph as the real-time graph backend for three related workloads:

  • GraphRAG: retrieval that combines text relevance with graph expansion and Cypher traversal.
  • AI Memory: semantic, episodic, and procedural memory in one connected graph.
  • Agentic AI: an execution and reasoning graph for tasks, runs, actions, outcomes, and policies.

Pathway remains the ingestion and API service. Memgraph is the graph execution and memory backend. SQLite FTS remains a local fallback/search index.

Services

ServiceEndpointPurpose
thilke-memgraph.servicebolt://127.0.0.1:7687Memgraph database for graph memory, GraphRAG, and reasoning paths
thilke-pathway-context.servicehttp://127.0.0.1:8090Ingestion, HTTP API, dual-write adapter
thilke-iii-worker.servicews://127.0.0.1:49134Exposes graph functions to iii

Memgraph data is persisted under /var/lib/thilke-agent/memgraph and mounted into the container.

Memory model

The adapter writes these node families:

  • (:ThilkeEntity) for repositories, issues, runs, artifacts, and procedures.
  • (:Memory) for all memory records.
  • (:Memory {layer: "semantic"}) for facts, entities, and issue knowledge.
  • (:Memory {layer: "episodic"}) for run history, traces, validations, and outcomes.
  • (:Memory {layer: "procedural"}) for playbooks, policies, and repeatable workflows.

Important relationships:

  • (repo)-[:THILKE_RELATION {kind: "has_issue"}]->(issue)
  • (run)-[:THILKE_RELATION {kind: "has_artifact"}]->(artifact)
  • (memory)-[:ABOUT]->(entity)

API surface

Pathway context endpoints:

curl -fsS http://127.0.0.1:8090/healthz
curl -fsS -X POST http://127.0.0.1:8090/v1/admin/refresh

GraphRAG search:

curl -fsS -H 'content-type: application/json' \
  -d '{"query":"agent memory GraphRAG","limit":8}' \
  http://127.0.0.1:8090/v1/graphrag/search

Memory lookup:

curl -fsS -H 'content-type: application/json' \
  -d '{"query":"jj recovery","layer":"procedural","limit":8}' \
  http://127.0.0.1:8090/v1/memory/lookup

Read-oriented Cypher:

curl -fsS -H 'content-type: application/json' \
  -d '{"query":"MATCH (m:Memory) RETURN count(m) AS memories","limit":5}' \
  http://127.0.0.1:8090/v1/memgraph/cypher

The Cypher endpoint also accepts params for safer automation:

{
  "query": "MATCH (r:ReasoningRun {run_id: $run_id})-[:PROPOSES]->(a:Action) RETURN r.run_id AS run_id, count(a) AS actions",
  "params": {"run_id": "019e53d7-cb42-7272-a077-a4fa901bb73f"},
  "limit": 5
}

Agentic AI reasoning graph

plan-issue mirrors its proposed execution path into Memgraph. This makes the agent plan queryable before any write action is approved, which is the first concrete slice of the Memgraph Agentic AI model.

For each issue planning run, Thilke writes:

  • (:ReasoningRun:AgentRun) with run_id, agent, status, summary, model_provider, model_tier, and recovery branch.
  • (:Task:GiteaIssue) for the source issue.
  • (:Action:ProposedAction) for each gated action, with action_id, kind, risk, risk_score, approval, dry_run, and ordinal.
  • (ReasoningRun)-[:PLANS_FOR]->(Task).
  • (ReasoningRun)-[:PROPOSES {ordinal}]->(Action).
  • (Action)-[:NEXT_ACTION]->(Action) for ordered execution-path traversal.

This lets agents and reviewers ask graph-native questions before writes occur:

curl -fsS -H 'content-type: application/json' \
  -d '{"query":"MATCH (r:ReasoningRun {run_id: $run_id})-[:PROPOSES]->(a:Action) RETURN r.run_id AS run_id, count(a) AS actions","params":{"run_id":"019e53d7-cb42-7272-a077-a4fa901bb73f"},"limit":5}' \
  http://127.0.0.1:8090/v1/memgraph/cypher

The current deployment was dogfooded with issue thilke/agent#1; the resulting graph contained one ReasoningRun, one GiteaIssue task, and five proposed actions connected by PROPOSES and NEXT_ACTION edges.

iii functions

The Thilke iii worker exposes:

  • thilke.graph.search
  • thilke.graph.memory_lookup
  • thilke.graph.cypher

This gives agents a stable capability-bus interface for GraphRAG, AI memory, and reasoning-graph queries without coupling agent code directly to Memgraph.

ADK integration plan

ADK-Rust should talk to memory through a ThilkeMemoryStore adapter:

  1. before planning: call GraphRAG/memory lookup for issue, repo, and agent-role context;
  2. during execution: append episodic events and observations;
  3. after execution: store summary, validation result, PR outcome, cost, model tier, and errors;
  4. during future planning: use graph edges and prior outcomes to score action paths.

The current implementation establishes the backend, APIs, and pre-write reasoning-plan mirror. The next step is to persist post-write outcomes from execute-approved and feed success/failure edges back into future planning.

Validation

systemctl is-active thilke-memgraph thilke-pathway-context
curl -fsS http://127.0.0.1:8090/healthz
curl -fsS -H 'content-type: application/json' \
  -d '{"query":"MATCH (m:Memory) RETURN count(m) AS memories","limit":5}' \
  http://127.0.0.1:8090/v1/memgraph/cypher