KMS-Agent: A Practical Architecture for Evolving AI Systems

Mar 26, 2026

Overview

KMS-Agent is a knowledge management system designed to build, maintain, and evolve AI agent behavior over time. Rather than treating each interaction as stateless, it constructs a persistent cognitive architecture where agents form behavioral patterns, track confidence levels, and adapt based on outcomes.

The system runs entirely locally, integrating n8n for workflow orchestration, Prisma for structured data, GraphQL for typed queries, and custom agents built on top. It's built for researchers and practitioners who need to understand and control how AI systems develop—not just how they respond.

Core Architecture

The Cognitive Loop

Every interaction follows a complete cycle:

Code

```

Stimulus → Processing → Action → Result → Conclusion → Evaluation → Adaptation

```

This isn't a shortcut. It's intentional. The system records not just answers, but the entire decision path. This enables agents to:

Recognize patterns in their own behavior

Identify when they're operating outside normal contexts

Adjust confidence levels based on outcome accuracy

Build reflexive responses to recurring situations

Knowledge Base with Epistemic Rigor

The system doesn't flatten knowledge into vectors. Instead, it models:

N-ary facts — multiple entities participating in relationships through defined roles

Temporal validity — facts have time ranges when they're true

Confidence tracking — every fact carries a trust level (0.0-1.0)

Contradiction management — conflicts are first-class objects, not errors

Knowledge spaces — contextual interpretation (private/shared/public)

Proposals and decisions — hypothesis testing with full history

This is closer to a symbolic knowledge representation than a vector database. It allows the system to reason about uncertainty explicitly.

Experience System (Reflex and Reaction)

Rather than generic behavior, the system models learned responses:

EXReflex — conditional and unconditional behavioral rules with effectiveness tracking

EXReaction — specific responses evaluated by agent, target user, and mentor perspectives

When a situation recurs, the system can retrieve and apply learned responses, and measure whether those responses remain effective.

Technical Implementation

AgentOrchestrator: The Central Node

The custom n8n node that powers agent behavior:

```ts

AgentOrchestrator {

mode: 'full' | 'validator' | 'nested'

model: string // OpenRouter or local

maxIterations: number

tools: Tool[]

memory: AgentMemory

systemMessage: string

}

```

Modes:

Full Agent — Standard agent loop with tool execution

Validator — Single LLM call, returns tool calls without execution

Nested — Multi-agent orchestration with streaming

The node handles streaming responses, tool call routing, error recovery, and memory integration.

Code-First Workflows

Workflows are TypeScript, not JSON:

```ts

class ChatAgentWorkflow extends AgentWorkflowFactory {

getConfig(agentCreds: AgentCredentials): AgentFactoryConfig {

return {

agentName: 'Chat Agent',

model: 'anthropic/claude-sonnet-4',

hasWebSearchAgent: true,

canSendMail: true,

}

}

}

```

This enables type-safe workflow definitions, dependency injection, and testing. It also makes workflows readable and maintainable—they're code, not visual diagrams.

Memory System

12-type MindLogs track:

Agent decisions and reasoning

Tool execution history

Outcome evaluations

Behavioral adaptations

Context shifts

Confidence changes

Tool calls are automatically recorded with:

Arguments and results

Success/failure status

Agent and session context

Semantic metadata for retrieval

The Memory Recall agent provides natural language search over this history, allowing agents to learn from their own past patterns.

Infrastructure

Next.js 16 + SSR — Frontend with server-side rendering

GraphQL (Pothos) — Type-safe API

Prisma ORM — Database migrations and type safety

PostgreSQL — Data persistence

Docker — Full containerization with dev/prod configs

n8n 2.1.1 — Workflow engine with custom nodes

JWT Auth — Production-ready authentication

Email integration via docker-mailserver allows agents to send and receive mail. World3D provides a multiplayer 3D environment with WebRTC voice chat for agent interactions.

What Makes This Different

1. Local-First Design

The entire system runs locally. No cloud dependency, no data exfiltration, no API rate limits. For research and personal use, this is critical.

2. Explicit Uncertainty

Rather than hiding confidence levels, the system tracks them. Agents know when they're uncertain and can adjust behavior accordingly.

3. Contradiction as Data

When the system encounters conflicting information, it doesn't pick one and discard the other. It records both, tracks which is more reliable, and adjusts over time.

4. Behavioral Continuity

Agents don't reset between sessions. They build patterns. They refine responses. They become more specialized to your use case over time.

5. Introspection Built In

The system can analyze its own behavior. A reflection subsystem allows agents to question their decisions, recognize patterns, and propose adjustments.

6. Testable Architecture

Workflows are code. Memory is queryable. Decisions are traceable. This makes testing, debugging, and improvement systematic rather than manual.

Use Cases

Research: Test hypotheses about agent learning, knowledge representation, and decision-making under uncertainty.

Personal AI Systems: Build an assistant that actually learns from your feedback instead of resetting daily.

Agent Development: Debug and understand exactly how agents make decisions, not just what they output.

Knowledge Engineering: Build domain-specific knowledge bases with explicit reasoning, not just embeddings.

Controlled Experimentation: Modify memory, behavior rules, or knowledge and measure the impact systematically.

Limitations

Not production SaaS — Designed for single users or small teams, not horizontal scaling

Requires setup — This is infrastructure, not a managed service

GPU helpful but optional — Local models work better on capable hardware, but cloud models are available

Still evolving — The system is actively developed; APIs may change

Current State

Version 1.4.0 includes:

Multi-modal agent orchestration with registry-based workflow management

WorkflowRegistry for centralized dependency resolution

Decompositor and useful-info agents for message analysis

Tool ecosystem: web search, email, GraphQL, file operations, code execution

3D world environment with multiplayer support

Memory recall system with semantic search

Complete documentation and Docker deployment

Getting Started

The recommended path:

Clone the repository

Run via Docker Compose (includes n8n, PostgreSQL, mailserver)

Configure an AI model (OpenRouter recommended, or local via LM Studio)

Send test requests to the webhook endpoint

Explore the knowledge base and agent logs through the web interface

Local development with Qwen3-8B on RTX 5080 is viable for research and personal use.

Who This Is For

AI researchers building understanding of agent behavior and learning

Engineers wanting deep control over AI system design

Organizations that can't use cloud APIs for privacy/compliance reasons

Enthusiasts interested in how cognitive architectures might work in practice

This is not a chatbot competitor. It's a framework for understanding and controlling how AI systems evolve.

Conclusion

KMS-Agent takes a different approach to AI systems: treating them as entities that learn, remember, adapt, and introspect. Rather than optimizing for speed or simplicity, it optimizes for understanding and control.

The code is clean. The architecture is deliberate. The thinking is clear. It's a system built by someone who understands both software engineering and AI, and it shows.

For the right use case, it's worth studying.

Repository: https://github.com/haih-net/agent

Documentation: https://github.com/haih-net/agent/tree/main/wiki