Skip to content

Repository files navigation

Belief Context Graph

Reasoning-Traceable Graph · Belief-Conditioned Loop

Python 3.11–3.13 License: MIT uv Website Documentation
WeChat Discord

Agent: gpt-5.6-luna with low-effort thinking · Graph/Summary: gpt-5.6-luna with thinking disabled · Harness: repository harness

Why Belief Context Graph

Current agent memory systems fall short. Conversation memory preserves history. Vector memory retrieves similar fragments. GraphRAG extracts entities and relations. Trace memory records tool calls. Temporal KGs track facts over time.

These systems answer retrieval questions: which text is relevant? which entities are related? what happened in the past?

But agents executing real tasks also need to answer belief questions:

  • Should I actually believe this fact?
  • Is it still valid, or has it expired?
  • Did it come from a reliable source?
  • Does it conflict with other evidence?
  • Is it certain enough to act on?
  • Did the outcome prove my prior belief wrong?

Belief Context Graph (BCG) upgrades agent memory from retrieval memory to belief context graph. It is a probabilistic, temporal, evidence-grounded and computational memory substrate that helps agents continuously maintain: what to believe, at what confidence, from which evidence, and whether uncertainty should block action. The result is agent memory you can query, audit, and trust.

Core capabilities:

  • Belief Extraction: Segment trajectories, extract structured beliefs that counts for agent reasoning and link them into a connected graph
  • Deterministic Confidence: Auditable posterior confidence computed from initial_confidence, evidence_confidence, and relation-derived factor_confidence; source reliability and stance quality set the prior, while relation weights and activation thresholds propagate support or contradiction deterministically
  • Evidence Provenance: Every belief carries exact-offset source references back to the originating conversation turn
  • Temporal Awareness: Run-based lifecycle with sessions and timestamps — know when each belief was formed and how it evolved
  • Relation Linking: Forward and backward relationship edges between beliefs, forming a casual decision graph/trace.

Live Demo

bcg-demo-release.mp4

Quick Start  ·  Architecture  ·  Case Study  ·  Project Status  ·  Comparison  ·  Contributing


Quick Start

Requires Python 3.11–3.13. The optional reference terminal Agent additionally requires Node.js 22.19+.

git clone https://github.com/bigai-nlco/belief-context-graph.git
cd belief-context-graph
make install
uv run bcg --version

Launch the bundled reference Agent to try BCG immediately — integrating BCG into your own Agent does not require this CLI:

uv run bcg

The first run walks you through model credentials, context mode, and Graph Construction backend, and saves your choices under ~/.bcg. See the documentation for everything else.

🔨  BCGRunner — build the first belief context graph  →  Construct the first BCG · Understand your graph

🧠  BCGMemory — query beliefs and assemble context  →  Read Memory · Memory Methods


Architecture

BCG is an optional context layer between an Agent and its model. In BCG mode, the initial user input and recent completed turns remain in the raw context, while older completed turns stream into Graph Construction; the resulting belief snapshot is then injected into the system prompt. Both the HTTP service and the Python SDK use the same backend registry, construction pipeline, confidence semantics, and graph artifacts.

BCG architecture: Agent context management and Python SDK feed unified or hybrid Graph Construction backends, which share an incremental belief graph pipeline and return Graph snapshots to the Agent system prompt


Gains of BCG for Agentic Tasks

This successful BrowseComp case (browsecomp-0836) shows Kimi K3 using belief identities and confidence from BCG instead of repeating an already completed search.

BrowseComp task, injected graph beliefs, and selected Kimi K3 thinking passages with graph references highlighted in red


Project Status

BCG currently provides a belief-native memory SDK, unified and hybrid graph-construction backends, an optional HTTP service, a reference Agent integration, reproducible benchmark tooling, and graph visualization support. The next development phase focuses on two directions:

  1. A more principled probabilistic foundation. Develop probability calculation and propagation methods that are more reasonable and better grounded in Bayesian inference or other mathematically justified uncertainty frameworks. This includes clarifying priors, likelihoods, evidence dependence, contradiction handling, graph-path effects, and calibration while preserving auditability.
  2. Deep Research. Extend BCG from belief-aware context management toward a Deep Research workflow that can plan investigations, track source provenance and temporal validity, reconcile conflicting findings, identify missing evidence, and produce auditable research outputs.

Comparison with Relevant Solutions

Agent memory systems serve different purposes. Below is a feature-level comparison of BCG against the most widely-used memory and knowledge graph solutions in the LLM agent ecosystem.

Mem0 Zep Letta (MemGPT) LangChain Memory LlamaIndex TrustGraph Semantica BCG
Belief-native extraction
Deterministic confidence
Evidence provenance
Temporal lifecycle
Relation linking
Local-first artifacts
Graph queryability
Merge / dedup
Conflict detection
Run without an independent DB

✅ Full support    ⚡ Partial / optional    ❌ Not supported


License

MIT — see the LICENSE file for details.


Corresponding and Contributing

We are very pleased to answer any questions about BCG: lijiaqi@bigai.ai, zlzheng@bigai.ai We appreciate your interest in contributing to our open-source initiative.

About

A context graph which is based on confidence-aware belief that drives more determinstic reasoning in long-horizon agents.

Topics

Resources

Contributing

Stars

158 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages