HANERMA

Hierarchical Atomic Nested External Reasoning & Memory Architecture

Perfect long-term memory. Atomic-verified reasoning. Intelligent routing. Calibrated confidence. The definitive open-source framework for reliable AI agents.

Built by Xerv

pip install hanerma View on GitHub

Verified Features

Auto Mode (Classifier)

Perfect
Correctly chose direct for simple questions, reasoning for math, memory for recall

Force Memory

Perfect
Always injected context, even on unrelated questions

Force Reasoning

Perfect
Applied full atomic reasoning even to trivial math

Force Both

Perfect
Combined memory + deep reasoning on every query

Direct Mode

Perfect
Bypassed all overhead — fastest responses

Per-Query Override

Perfect
Successfully forced modes on individual calls

Memory Persistence

Perfect
Accurately recalled multiple facts across turns

Save/Load Memory

Perfect
JSON persistence worked — restored state correctly

Internal Logging

Perfect
Full transparency into every stage

HANERMA vs LangChain

HANERMA

  • Built-in perfect long-term memory
  • Atomic nested reasoning with verification
  • Intelligent zero-shot routing
  • Native confidence calibration
  • Minimal, stupid-easy API
  • Lightweight & focused

LangChain

  • Memory requires complex setup
  • Reasoning chains manual & verbose
  • No built-in routing intelligence
  • Confidence not native
  • Heavy, complex API surface
  • Many dependencies

HANERMA is purpose-built for core intelligence with zero overhead. LangChain excels at complex tool orchestration — HANERMA wins when you want reliability and simplicity out of the box.

Extend & Experiment

HANERMA is intentionally minimal and fully overridable — perfect for experimentation and custom agents.

Add Tools

            class ToolAgent(HANERMA):
    def web_search(self, query):
        # Your search logic
        return result

    def ask(self, prompt):
        if "search" in prompt.lower():
            return self.web_search(prompt)
        return super().ask(prompt)
            
            
Copied!

Custom Reasoning

            class ReActAgent(HANERMA):
    def _reasoning(self, prompt):
        # Implement ReAct, Tree-of-Thought, etc.
        return custom_reasoning(prompt)
            
            
Copied!

Persistent Memory

            import json

# Save memory
with open("memory.json", "w") as f:
    json.dump(ai.memory_store, f)

# Load memory
with open("memory.json") as f:
    loaded = json.load(f)
    for item in loaded:
        embedding = ai._get_embedding(item["text"])
        ai.memory_store.append({"text": item["text"], "embedding": embedding})
            
            
Copied!

Subclass HANERMA and override any method. The core is rock-solid — your experiments are limitless.

Core Architecture

Atomic Reasoning

Decomposes into smallest verifiable atoms with bottom-up synthesis and cross-consistency checks.

External Memory

Real sentence-transformers embeddings for unlimited conversation history recall.

Intelligent Routing

Zero-shot classifier automatically selects optimal path.

Calibrated Confidence

Every response ends with accurate Confidence: X%.

Installation

        pip install hanerma
        
        
Copied!

Python ≥ 3.8 • Dependencies auto-installed

Usage

Direct API Key

          from hanerma import HANERMA

ai = HANERMA(api_key="sk-or-your-key", model="any-openrouter-model")

print(ai.ask("Your question"))
          
          
Copied!

Environment Variable

          import os
os.environ["OPENROUTER_API_KEY"] = "sk-or-your-key"

from hanerma import HANERMA
ai = HANERMA(model="meta-llama/llama-3.1-70b")

print(ai.ask("Question"))
print(ai.ask("What was my previous question?"))
          
          
Copied!

FAQ

What makes HANERMA different from LangChain?

HANERMA is laser-focused on core intelligence (memory, reasoning, routing, calibration) with minimal code. LangChain is powerful for complex tool chains but requires heavy configuration.

Can I extend HANERMA for my experiments?

Yes — subclass and override any method. Add tools, custom reasoning, persistent storage, multi-agent logic. The core is deliberately minimal for maximum experimentation.

Is memory permanent across runs?

In-memory during instance lifetime. Save/load memory_store to JSON or vector DB for persistence.

Can I see internal logs?

Yes — ai.logs provides full transparency into classifier, memory, and reasoning stages.