Neo4j Context Graph Decision-Aware Agent Framework
Design AI agents that make explainable, policy-grounded decisions by wiring context graphs, memory layers, and a structured decision workflow into your agentic system.
// TL;DR
The Neo4j Context Graph Decision-Aware Agent Framework is a structured approach for building AI agents that make explainable, policy-grounded decisions using context graphs, a three-layer memory model, and a compartmentalised decision workflow. Unlike generic prompt-engineered agents, it stores rules, policies, and decision precedents in a graph database so agents can handle unanticipated edge cases with traceable reasoning. Use it when building or auditing AI agents that take consequential or autonomous actions — especially where decision traceability, accountability, and safe handling of the 1% edge case are non-negotiable requirements.
// When should you use the Neo4j Context Graph Decision-Aware Agent Framework?
Use this skill when building or auditing an AI agent that must take consequential or autonomous actions — especially where the agent will encounter situations its prompt engineering did not anticipate, or where decision traceability and accountability are required.
// What inputs do you need to design a decision-aware context graph agent?
- agent_objectiverequired
The goal the agent is trying to achieve (e.g., 'keep fridge stocked with Red Bull', 'assess loan eligibility'). - operating_environmentrequired
The domain or context in which the agent operates (e.g., consumer purchasing, medical guidance, financial services). Stakes level must be assessed. - causality_chainrequired
The sequence of reasoning steps and actions that led the agent to the current decision point. - existing_rules_and_policies
Hard and soft business rules available — formal (business process docs) or informal (Slack channels, Google Docs, etc.). - prior_decisions
Historical precedent stored in the context graph — what was decided before in similar circumstances. - agent_authority_scoperequired
What the agent is and is not authorised to act on autonomously.
// What are the core principles behind context graph decision-aware agents?
Context Graph over Knowledge Graph
A knowledge graph gives an agent what it knows. A context graph additionally gives it the why — the rules, policies, and decision precedents that govern what it should do. The shift from knowledge to context graph is the shift from a capable agent to a decision-aware agent.
Three-Layer Memory Model
Agents require three memory types working together: Short-Term Memory (conversation state and history), Long-Term Memory (generalised knowledge about organisations, people, and things), and Reasoning Memory (policies, rules, and prior decision rationale that tell the agent why to act).
Explicit Over Implicit
Much of the engineering work for decision-aware agents is converting implicit human understanding — about stakes, context, constraints — into explicit, stored, retrievable knowledge. If the agent was not told it, it will default to statistical averages, which fails the 1% edge case.
Reference Class Validation
Before deciding, classify which population or reference class the current situation belongs to. Statistical majority behaviour is dangerous when the cost of being in the minority is catastrophic — e.g., a drug safe for 99% that is fatal for 1%.
Propose, Don't Decide (Compartmentalised Agents)
The analysis agent's job is only to generate a proposal of alternatives with pros and cons — not to make the final choice. A separate agent (or human) with decision authority makes the choice. This separation of analysis and authority is core to safe multi-agent systems.
Act or Escalate — Never Guess
If an agent has certainty and authority, it acts. If it lacks either, it escalates — to a higher-privilege agent or a human in the loop. Guessing under uncertainty without escalation is the failure mode this framework is designed to prevent.
Decision Tracing and Accountability
Every decision — made or deferred — must have its full reasoning chain, considerations, alternatives, and outcome recorded back into the context graph. This creates precedent for future agents and enables auditability.
// How do you apply the context graph decision-aware agent framework step by step?
- 1
Frame the Local Context
Capture three things: (1) the agent's current objective, (2) the causality — the reasoning chain and actions that produced this decision point, and (3) the operating environment and its stakes level (e.g., consumer commerce vs. medical care vs. financial services). Without this framing the agent cannot weight risks correctly.
- 2
Load the Global Context from the Context Graph
Query the context graph for two inputs: (1) Prior Decisions — what was decided before in comparable circumstances; consistency is valuable unless rules have changed. (2) Hard and Soft Rules — formally documented policies and informal guidance. Both must be loaded and held in tension. A prior decision may need to be overruled by a rule that was updated since.
- 3
Perform Reference Class Validation
Before risk-value analysis, classify the situation: which population or scenario class does this case actually belong to? Do not assume the majority case applies. Explicitly ask: Is this the 99% or the 1%? This step prevents statistically-correct-but-individually-catastrophic decisions.
- 4
Run Risk-Value Analysis
Assess the risk side: Is the decision reversible? What is the cost of being wrong? What are the specific risks for the players involved (not just the general case)? Assess the value side: What is being maximised (savings, safety, speed) or minimised (cost, harm)? These must be explicit — the agent cannot infer them reliably from general knowledge.
- 5
Generate Alternatives Proposal (Analysis Agent Output)
The output of the analysis stage is NOT a decision. It is a structured proposal listing available options with pros and cons for each. This proposal is handed off — do not collapse analysis and choice into a single agent step.
- 6
Check Authority and Act or Escalate (Decision Agent)
A separate agent (or human) receives the proposal and asks: Do I have sufficient certainty? Do I have the authority to act? If yes to both: rank the options and execute. If no to either: escalate to a higher-privilege agent or trigger the human-in-the-loop oversight sub-process. Deferral (taking no action pending escalation) is a valid and sometimes correct output state.
- 7
Record Decision Trace Back into Context Graph
Regardless of outcome (action taken, escalated, or deferred), write the complete record to the context graph: what was considered, what was rejected, the reasoning chain, the decision made, and the actions taken. This becomes Reasoning Memory and serves as precedent for future agents. This is the self-learning loop that improves agent quality over time.
// What are real-world examples of context graph decision-aware agents in action?
An autonomous personal-finance agent is tasked with keeping a household stocked with a specific consumable. It detects low stock and prepares to reorder.
Local context: objective is restock; causality is low-stock detection; environment is personal consumer purchasing — low stakes. Global context: load prior purchase history and any soft rules (e.g., budget guidance stored in the graph). Reference class validation: is rent or another large expense imminent? Risk analysis: decision is reversible (can cancel order), cost of being wrong is minor. Value analysis: what is being optimised — convenience vs. budget? Proposal: order now vs. wait 3 days vs. reduce quantity. Decision agent checks authority (has account access, certainty is high) and executes. Trace is recorded.
A clinical decision-support agent must recommend a treatment for a patient presenting with a common symptom.
Local context: objective is treatment recommendation; environment is medical — extremely high stakes. Reference class validation is critical: the agent must explicitly determine whether the patient falls in the 99% majority case or a 1% contraindicated minority before any analysis proceeds. Hard rules from the context graph (clinical protocols, contraindication policies) take precedence over prior decisions. Risk analysis: decision may not be reversible; cost of being wrong includes patient harm. The analysis agent produces alternatives with risk profiles only. The decision agent escalates to a licensed human clinician because authority to prescribe does not exist at the agent level. Full reasoning trace is stored.
// What mistakes should you avoid when building context graph decision-aware agents?
- Conflating knowledge graphs with context graphs — storing only facts without storing the why (policies, rules, and decision rationale) leaves agents unable to make principled decisions.
- Using a single agent for both analysis and decision-making — collapsing these roles removes the authority checkpoint and produces unaccountable autonomous action.
- Relying on statistical majority behaviour without reference class validation — the 99% answer is fatal for the 1% case, and agents will default to it unless explicitly instructed otherwise.
- Leaving hard and soft rules implicit in prompts rather than encoding them in the context graph — informal rules degrade or disappear; graph-stored rules persist and can be queried.
- Skipping the decision trace step — without recording reasoning back to the context graph, agents cannot learn from precedent and auditability is lost.
- Allowing agents to guess under uncertainty rather than escalate — without an explicit 'act or escalate' checkpoint, autonomous agents will take actions they lack the authority or certainty to support.
- Assuming the framework generalises without domain tuning — every step of this workflow has domain-specific particulars; the framework is a skeleton, not a finished product.
// What are the key terms and concepts in the context graph agent framework?
- Context Graph
- A graph database structure that stores not only factual knowledge (what) but also policies, rules, and decision precedents (why), enabling agents to become decision-aware rather than merely knowledge-capable.
- Decision-Aware Agent
- An AI agent equipped with a context graph and decision workflow that allows it to handle situations not covered by its initial instructions, making principled choices grounded in rules, precedent, and explicit risk-value analysis.
- Short-Term Memory
- The layer of agent memory that captures the current conversation state and interaction history — what has happened in this session.
- Long-Term Memory
- The layer of agent memory that stores generalised, persistent knowledge about organisations, people, and entities — the stable world model.
- Reasoning Memory
- The layer of agent memory that stores policies, rules, and prior decision rationale — the why that governs agent behaviour and enables consistent, accountable decisions.
- Reference Class Validation
- A risk analysis step that explicitly classifies the current case into its relevant population segment before deciding, preventing the agent from applying majority-case logic to minority-case situations where that logic fails or causes harm.
- Hard and Soft Rules
- Hard rules are formally documented, non-negotiable policies. Soft rules are informal guidance (e.g., Slack channels, internal docs) that represent cultural or operational norms. Both must be encoded in the context graph and balanced against each other.
- Act or Escalate
- The binary decision gate at the authority-check step: if the agent has both certainty and authority, it acts; if it lacks either, it escalates to a higher-privilege agent or human-in-the-loop oversight sub-process.
- Human-in-the-Loop Oversight Sub-process
- The escalation pathway triggered when an agent determines it lacks the authority or certainty to act autonomously — routing the decision to a human or a higher-privilege agent.
- Decision Trace
- The complete recorded artefact of a decision event: what was considered, what was rejected, the full reasoning chain, the outcome, and actions taken — stored back into the context graph as precedent for future agents.
- Text to Cypher
- A tool that translates natural language queries into Cypher, the Neo4j graph query language, enabling agents to retrieve structured graph data without requiring users or agents to write graph queries manually.
// FREQUENTLY ASKED QUESTIONS
What is the Neo4j Context Graph Decision-Aware Agent Framework?
It is a framework for designing AI agents that make explainable, policy-grounded decisions by combining context graphs (storing facts, rules, policies, and decision precedents), a three-layer memory model (short-term, long-term, and reasoning memory), and a structured workflow that separates analysis from decision authority. The framework ensures agents act only when they have both certainty and authority, and escalate otherwise.
What is a context graph and how is it different from a knowledge graph?
A context graph extends a knowledge graph by storing not just factual data (what) but also policies, rules, and prior decision rationale (why). While a knowledge graph makes an agent capable, a context graph makes it decision-aware — able to reason about constraints, precedent, and governance rather than defaulting to statistical averages when encountering novel situations.
How do you build a decision-aware AI agent with context graphs?
Start by framing the agent's local context (objective, causality chain, stakes level). Then load global context from the context graph — prior decisions and rules. Perform reference class validation to avoid majority-case bias. Run risk-value analysis, generate an alternatives proposal from an analysis agent, and hand it to a separate decision agent that either acts or escalates. Record the full decision trace back into the context graph.
How do you implement the three-layer memory model for AI agents?
Implement three distinct memory layers: Short-Term Memory captures the current conversation state and session history. Long-Term Memory stores persistent, generalised knowledge about entities, organisations, and people. Reasoning Memory stores policies, rules, and prior decision rationale in the context graph. All three layers work together so the agent knows what happened, what exists, and why it should act a certain way.
How does the context graph framework compare to standard RAG-based agent architectures?
Standard RAG retrieves documents to augment prompts but lacks structured decision governance. The context graph framework goes further by encoding policies, rules, and decision precedents as graph relationships, enabling reference class validation, authority checks, and decision tracing. RAG answers questions; context graphs govern decisions. RAG is flat retrieval; context graphs model the causal and regulatory structure around decisions.
When should I use the context graph decision-aware agent framework?
Use it when your AI agent takes consequential or autonomous actions — especially in domains like healthcare, finance, legal, or procurement where edge cases carry high costs. It is essential when prompt engineering alone cannot anticipate all situations, when you need decision traceability for compliance or auditing, or when the cost of the agent guessing wrong in a minority case is catastrophic.
What results can I expect after implementing the context graph agent framework?
Expect agents that handle unanticipated edge cases without guessing, produce fully auditable decision trails, and improve over time through stored precedent. You gain clear separation between analysis and authority, reducing unaccountable autonomous actions. Escalation rates will initially increase (a feature, not a bug) as the agent correctly defers uncertain or unauthorized decisions instead of defaulting to statistically average responses.
What is reference class validation in AI agent decision-making?
Reference class validation is a risk analysis step where the agent explicitly classifies the current situation into its relevant population segment before deciding. Instead of assuming the majority case applies, the agent asks: 'Is this the 99% or the 1%?' This prevents statistically-correct-but-individually-catastrophic decisions — for example, recommending a drug safe for 99% of patients to a patient in the 1% contraindicated group.
What does 'act or escalate' mean in multi-agent systems?
Act or escalate is a binary decision gate: if the agent has both sufficient certainty about the situation and the authority to act, it proceeds. If it lacks either, it escalates to a higher-privilege agent or triggers human-in-the-loop oversight. This prevents the most dangerous failure mode — agents guessing under uncertainty without authorization, which produces unaccountable autonomous actions.
How do you separate analysis agents from decision agents?
The analysis agent's job is strictly to generate a structured proposal listing available options with pros and cons — it never makes the final choice. A separate decision agent (or human) receives this proposal, verifies it has both certainty and authority, and then either selects an option and executes or escalates. This compartmentalisation creates an authority checkpoint that prevents unaccountable action.
Can I use this framework without Neo4j?
The framework's principles — context graphs, three-layer memory, reference class validation, act-or-escalate — are database-agnostic in concept. However, Neo4j's native graph model makes implementing context graphs, traversing policy relationships, and querying decision precedent significantly more natural than relational or document databases. Tools like Text-to-Cypher further simplify agent-graph interaction. Other graph databases could substitute, but the framework was designed with Neo4j's capabilities in mind.
Turn Any YouTube Video Into An AI Skill
SkillForge captures a creator's exact methodology from their video and turns it into a reusable AI skill you can invoke in Claude, ChatGPT, or any LLM.
Forge your own skill