Skip to main content

ContextOn.AI OSS

Knowledge Graphs with Confidence Scoring and Failure Learning

By ODEFTO AI Labs | Enterprise Version (ContextOn.AI)


What is ContextOn.AI OSS?

ContextOn.AI OSS is an open-source knowledge graph engine for AI agents that introduces confidence-aware, failure-learning graph memory.

Unlike existing tools, ContextOn.AI OSS:

  • ๐ŸŸข Scores confidence - Every piece of knowledge has a trust indicator
  • ๐Ÿ”ด Learns from failures - Marks unreliable knowledge so agents avoid it
  • ๐Ÿ“Š Shows quality badges - Visual trust indicators (๐ŸŸข๐ŸŸก๐Ÿ”ด)
  • ๐Ÿ’ก Suggests questions - Graph tells you what it can answer
  • ๐Ÿ”— Resolves entity aliases - Links "PM-JAY" to "Pradhan Mantri Jan Arogya Yojana"
  • ๐Ÿ› ๏ธ Skills - Stores reusable procedures ("how to") with steps and confidence
  • ๐Ÿงฐ Tool registry memory - Tracks tools, their descriptions, and which ones fail
  • ๐Ÿ“ฆ Auto-context injection - get_context() assembles confident, badge-annotated context for agents
  • ๐Ÿงน Memory hygiene - Decay sweeps flag stale / low-confidence knowledge for re-verification
  • ๐ŸŽญ Per-agent scoping - Filter knowledge by agent (transparency)
  • ๐Ÿ›ฐ๏ธ Works with Claude/Cursor - MCP server included
  • ๐ŸŒ Web demo - contexton-ai-oss web runs a browser demo of everything

Quick Start

Installation

pip install contexton-ai-oss

Basic Usage

from contexton_ai_oss import ContextGraph

# Create a graph
graph = ContextGraph()

# Ingest knowledge from conversations
graph.ingest(
    query="What is PM-JAY?",
    answer="Pradhan Mantri Jan Arogya Yojana is health insurance for poor families",
    agent_id="health-agent"
)

# Query with confidence ranking
results = graph.query("PM-JAY coverage")
for result in results:
    print(f"{result['badge']} {result['node']['content'][:50]}")
    print(f"   Confidence: {result['confidence']:.1%}")

Recording Failures (KEY FEATURE)

# When your agent gives a wrong answer, tell the graph:
graph.record_failure(
    query="What is PM-JAY?",
    answer="It's a housing scheme",
    reason="Incorrect - it's health insurance, not housing"
)

# Confidence in the related knowledge drops (๐Ÿ”ด) and failure observations
# are never returned in query results.

# When the agent later gives a correct answer, record the success:
graph.record_success(
    query="What is PM-JAY?",
    answer="It's health insurance for poor families"
)

# Confidence is restored.

Visualizing the Graph

# Generate interactive HTML visualization
graph.visualize("graph.html")
# Open graph.html in your browser

Why ContextOn.AI OSS is Different

Feature Graphify Graphiti Mem0 ContextOn.AI OSS
Knowledge graphs โœ… โœ… โŒ โœ…
Agent memory โŒ โœ… โœ… โœ…
Confidence scoring โŒ โŒ โŒ โœ…
Failure learning โŒ โŒ โŒ โœ…
Quality badges โŒ โŒ โŒ โœ…
Suggested questions โŒ โŒ โŒ โœ…
Simple to use โœ… โŒ โœ… โœ…

Key Differentiator: No other tool learns from failures. See COMPARISON.md for verified market analysis.


Key Features

1. Confidence Scoring

Every node and edge has a confidence score (0.0-1.0) based on:

  • How many times it's been verified
  • How old the information is
  • How many times it's failed
# Get confidence breakdown
node = graph.get_node("node_id")
breakdown = graph.confidence_engine.get_confidence_breakdown(node)
print(breakdown)
# {'mentions': 5, 'base_score': 1.0, 'days_since_verified': 2, ...}

2. Failure Learning (NOVEL)

No other tool learns from mistakes. ContextOn.AI OSS does:

# Record a failure
graph.record_failure(
    query="What is X?",
    answer="Wrong answer",
    reason="Because Y"
)

# The graph now avoids paths that led to this failure
# Future queries prefer more reliable knowledge

3. Quality Badges

See at a glance which knowledge is trustworthy:

  • ๐ŸŸข High confidence (โ‰ฅ0.8): Verified, reliable
  • ๐ŸŸก Medium confidence (0.5-0.8): Needs verification
  • ๐Ÿ”ด Low confidence (<0.5): Unreliable, verify before using

4. Suggested Questions

The graph analyzes itself and suggests questions it can answer:

suggestions = graph.suggest_questions()
for s in suggestions:
    print(f"{s['badge']} {s['question']}")
    print(f"   Reason: {s['reason']}")

Use Cases

1. AI Agent Memory

Give your agents persistent memory that learns and improves:

# Agent remembers past conversations
graph.ingest("How do I reset password?", "Go to settings โ†’ security")

# Later, agent can retrieve this knowledge
results = graph.query("password reset")

2. Knowledge Base

Build a knowledge base that tracks reliability:

# Add knowledge with confidence
graph.add_node("PM-JAY covers 5 lakh per family", confidence=0.9)

# Query returns confidence scores
results = graph.query("PM-JAY coverage")

3. Multi-Agent Systems

Agents share knowledge and learn from each other:

# Agent A learns something
graph.ingest("X causes Y", agent_id="agent-a")

# Agent B can query this knowledge
results = graph.query("what causes Y")

Integration with AI Assistants

Claude Code / Cursor / Codex (via MCP)

Install with MCP support, then start the server:

pip install "contexton-ai-oss[mcp]"

# stdio transport (recommended for Claude Code / Cursor)
contexton-ai-oss serve

# or streamable HTTP
contexton-ai-oss serve --port 8080

Add to Claude Code's MCP config (.mcp.json):

{
  "mcpServers": {
    "contexton-ai-oss": {
      "command": "contexton-ai-oss",
      "args": ["serve"]
    }
  }
}

Exposed tools: ingest, query, record_failure, record_success, suggest_questions, get_stats, get_aliases, resolve_aliases, get_confidence_breakdown, visualize.

Cursor

# Add to .cursor/rules
ContextOn.AI OSS is available for knowledge retrieval.
Use contexton-ai-oss query for knowledge questions.

Custom Agents

from contexton_ai_oss import ContextGraph

class MyAgent:
    def __init__(self):
        self.memory = ContextGraph()
    
    def answer(self, query):
        # Retrieve relevant knowledge
        knowledge = self.memory.query(query)
        
        # Use knowledge to answer
        return self.generate_answer(query, knowledge)
    
    def learn(self, query, answer, correct):
        if correct:
            self.memory.record_success(query, answer)
        else:
            self.memory.record_failure(query, answer)

Command Line Interface

# Ingest a conversation turn
contexton-ai-oss ingest "What is PM-JAY?" "PM-JAY is health insurance for poor families"

# Query with confidence-ranked results
contexton-ai-oss query "PM-JAY coverage"

# Record that an agent gave a wrong / correct answer
contexton-ai-oss record-failure "What is PM-JAY?" "It's a housing scheme" --reason "wrong"
contexton-ai-oss record-success "What is PM-JAY?" "It's health insurance"

# Skills (procedures)
contexton-ai-oss procedure ingest "Reset password" --steps "Open settings; Go to security; Click reset"
contexton-ai-oss procedure get "Reset password"

# Tools
contexton-ai-oss tools register send_email --description "Sends an email"
contexton-ai-oss tools list
contexton-ai-oss tools outcome send_email --error "SMTP timeout"

# Auto-context for agents
contexton-ai-oss context "PM-JAY coverage" --session sess-1

# Memory hygiene + per-agent view
contexton-ai-oss hygiene
contexton-ai-oss agent-memory health-agent

# Statistics, aliases, visualization, browser demo
contexton-ai-oss stats
contexton-ai-oss aliases
contexton-ai-oss visualize graph.html
contexton-ai-oss web --port 8080   # full browser demo

# All commands accept --data-dir DIR to persist the graph to disk

Documentation


Enterprise Features

ContextOn.AI OSS is the open-source version, built by ODEFTO AI Labs. For enterprise features, see ContextOn.AI:

Feature ContextOn.AI OSS ContextOn.AI (Enterprise)
Basic graph building โœ… โœ…
Confidence scoring โœ… โœ… Enhanced
Failure learning โœ… โœ… Enhanced
Quality badges โœ… โœ…
Isolation โŒ โœ…
Quality auditing โŒ โœ… 5-dimension scoring
Drift detection โŒ โœ…
Enterprise connectors โŒ โœ… SAP, ServiceNow, Salesforce
Compliance reporting โŒ โœ…

Contributing

We welcome contributions! See CONTRIBUTING.md.


License

Apache 2.0 - See LICENSE


Support


Acknowledgments

Built by ODEFTO AI Labs.

Inspired by Graphify, Graphiti, and Mem0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contexton_ai_oss-0.4.0.tar.gz (814.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contexton_ai_oss-0.4.0-py3-none-any.whl (71.2 kB view details)

Uploaded Python 3

File details

Details for the file contexton_ai_oss-0.4.0.tar.gz.

File metadata

  • Download URL: contexton_ai_oss-0.4.0.tar.gz
  • Upload date:
  • Size: 814.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for contexton_ai_oss-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6f4050aca61d774be6a38006cad5337e89eafbafcd86d941c557cb101c918ee2
MD5 5ede639ff6826013f859af90993bad14
BLAKE2b-256 d4c6dfebad37cba061dd50aed7146f4ae6de65f9e29933159d7a592e077b9824

See more details on using hashes here.

File details

Details for the file contexton_ai_oss-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for contexton_ai_oss-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ed1852ccaf7975f6e238e78ebadcadd182018f4619338fb20207d4d8a962d0d
MD5 0dc53c82a465654172e383dfad619b2d
BLAKE2b-256 735c5a6be96878653c163f70697dbf598825b1cac9ac5b579a13213cd0616c56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page