Skip to content

Repository files navigation

ANTHROPOMORPHIC-AGENT-ENGINE banner

agent psychology spl-v8.0

Anthropomorphic Psychology · SPL Pure Core V8.0

[简体中文](README-zh.md) | English

✦ About

ANTHROPOMORPHIC-AGENT-ENGINE is an anthropomorphic psychology engine built on SPL Pure Core V8.0. It models cognition, emotion, motivation, and social behavior as composable subsystems, giving AI agents human-like internal states and consistent personalities that produce self-consistent, credible, emotionally resonant behavior over long-term interactions.

ANTHROPOMORPHIC-AGENT-ENGINE overview

— ✦ —

✦ Quick Start

# Primary: GitHub
git clone https://github.com/nohn3043-arch/Anthropomorphic-Agent-Engine.git
# Mirror: Gitee
# git clone https://gitee.com/nohn-ecosystem/Anthropomorphic-Agent-Engine.git
cd Anthropomorphic-Agent-Engine
# Pure Python ≥3.8 — standard library only, no dependencies
python sujin-demo                    # Full engine demo (character: Su Jin)
python "feature/language style.py"   # Language-style rendering demo
python tests/run_conformance.py      # Determinism / replayability conformance suite

The core file SPL-anthropic-engine.py is a library — it has no __main__ entry point, so running it directly produces no output. Load it via importlib (see Usage below) or run one of the demo entry points above.

Load the engine

import importlib.util
spec = importlib.util.spec_from_file_location("spl_core", "SPL-anthropic-engine.py")
spl = importlib.util.module_from_spec(spec); spec.loader.exec_module(spl)

core = spl.SPLPureCoreV7_3()
core.process_vector({"belonging": 0.5, "threat": -0.1}, 1.0)
print(core.snapshot())

⚠️ PyPI release is frozen. spl-agent-engine is on PyPI, but its latest release is 0.4.0 (2026-09-02). The packaging files were removed from this repository in commits e39a606 / 7d36ff1 and have not been rebuilt, so the PyPI package no longer tracks the repository sources. Use the clone above for current behaviour.

— ✦ —

✦ Core — SPL Pure Core V8.0

The engine models the general human mental architecture as deterministic, continuous-state subsystems — no LLM, no randomness, fully replayable.

Reproducibility precondition. "Fully replayable" holds only after a virtual clock is injected via core.set_clock(t). Without it, _now() falls back to time.time(), and two runs of the same input sequence produce different results. Any external reproducibility claim must state this precondition. It is asserted by tests/ — cases S1–S4, including a negative test that requires the natural clock to be non-reproducible.

  • 8-Dimensional Emotion Fluid — joy / anger / fear / trust / alienation / tension / guilt / shame, each a continuous state with its own target and baseline.
  • Trauma & Memory — trauma nodes, memory reconsolidation, Ebbinghaus-style forgetting, suppression–rebound and latent pressure avalanche.
  • Trust & Relationships — trust capacity erosion (chronic neglect decays max_trust).
  • Mental Metabolism — excitation–arousal, dynamic viscosity, psychological time, energy–fatigue metabolism, and a virtual clock for testing and replay.
  • V8.0 Extensions — slow-variable mood layer, shame dimension independent of guilt, self-esteem dynamics, sleep / dream processing (REM consolidation + fear extinction + sleep debt), expectation system (hope / anxiety / disappointment), cognitive dissonance, and extended defense mechanisms (denial / rationalization / displacement).
  • Token Metering — TokenUsage dataclass + TokenStats accumulator, aggregating prompt / completion / total tokens across multiple LLM calls with per-model breakdown and JSON export. AuditLogger.log_llm_call automatically records token usage, latency, and success/failure for each call. Available in both the main engine and the minor-protection variant.

✦ Composable Modules

Module File Responsibility
Narrative Mapper SPL-anthropic-engine.py External, replaceable personality layer (optimistic / paranoid / misanthropic), translates events into interoceptive vectors.
Identity Engine feature/Identity module.py Multi-identity model; identity conflict injects persistent baseline tension.
Goal / Value / Bias / World feature/*.py Composable drives, valuations, cognitive biases, and world-model priors.
Language Style Renderer feature/language style.py Translates internal states into "how the character should speak" style directives / line rendering.

— ✦ —

✦ Usage

The engine file uses hyphenated naming by design — load directly (or run as a script):

import importlib.util
spec = importlib.util.spec_from_file_location("spl_core", "SPL-anthropic-engine.py")
spl = importlib.util.module_from_spec(spec); spec.loader.exec_module(spl)

core = spl.SPLPureCoreV7_3()
# External events are mapped to interoceptive vectors by the (replaceable) personality layer
vec = spl.NarrativeMapper.map_event("insult", intensity=1.0)
# Feed `vec` into `core`, evolving emotion / trust / trauma states over time

Token Metering

stats = spl.TokenStats()   # `spl` = module loaded via importlib (see above)

# Record usage after each LLM call
usage = spl.TokenUsage(prompt_tokens=120, completion_tokens=80,
                       total_tokens=200, model="gpt-4")
stats.record(usage)

# Summary
print(stats.summary())
# {'call_count': 1, 'total_prompt_tokens': 120, 'total_completion_tokens': 80,
#  'total_tokens': 200, 'by_model': {'gpt-4': {...}}}

# Export JSON report
stats.export_json("token_report.json")

The audit logger AuditLogger also automatically records each LLM call:

logger = spl.AuditLogger(log_dir="logs")
logger.log_llm_call(model="gpt-4", prompt_preview="Hello...",
                   usage=usage, duration_ms=350.5, success=True)

— ✦ —

✦ Project Structure

ANTHROPOMORPHIC-AGENT-ENGINE/
├── SPL-anthropic-engine.py     # Core engine (SPL Pure Core V8.0), NarrativeMapper,
│                               #   AuditLogger / TokenStats, LLM adapter interface
├── feature/                    # Composable modules (integration-side configuration)
│   ├── Goal module.py          #   goal graph · conflict level · emotion vector
│   ├── Identity module.py      #   identity nodes · strength · conflict
│   ├── bias module.py          #   appraisal bias profiles (paranoid / optimistic / depressive)
│   ├── value module.py         #   core-value threat · emotion amplification
│   ├── world module.py         #   belief model · prediction error
│   └── language style.py       #   LanguageStyleEngine — renders prompt_injection for the LLM
├── tests/                      # Determinism / replayability conformance suite (zero-dependency)
│   ├── run_conformance.py      #   runner: python tests/run_conformance.py
│   ├── conformance_vectors.json  # standard vectors + expected hashes
│   └── README.md               #   suite docs, incl. the clock precondition
├── minor-protection/           # Minor-protection variant (age gate + four-layer protection)
│   ├── SPL-anthropic-minor-engine.py
│   └── SPL-anthropic-minor-server.py
├── docs/                       # Public spec: anthromorphic-agent-engine-standards.md
├── assets/                     # banner.svg / overview.svg (+ .png exports)
├── sujin-demo                  # Reference demo script (single file, no LLM calls)
├── logs/                       # Runtime audit logs (JSONL, untracked)
├── banner.png
├── IMDA_AI_Verify_Causal_Audit_Report.pdf
└── LICENSE

— ✦ —

✦ Live Demo

Live Demo

Interactive demo: https://www.nohnlins.com/your-soulmate/

— ✦ —

✦ Minor-Protection Variant

A compliance-mitigated variant for underage (<18) emotional companionship scenarios, located in minor-protection/, with zero third-party dependencies (pure standard library). It applies mechanism-level risk reduction to the main engine SPLPureCoreV7_3 rather than output-side filtering, and includes a demonstrable compliance framework for minors.

⚠️ Compliance Notice: This directory is a research / demo compliance framework intended to demonstrate the protective capabilities and data mechanisms required for underage emotional companionship. Before launching a production service, you must complete legal review, DPIA / security assessment / algorithm filing, and connect real guardian notification channels with region-specific crisis resources.

📄 Full compliance documentation (mechanism-to-article mapping, known limitations disclosure, production deployment obligations): minor-protection/COMPLIANCE.md

Differences from Main Engine (Mechanism-Level Risk Reduction)

Dimension Main Engine SPL-anthropic-engine.py Minor Variant minor-protection/
Trauma nodes / trauma accumulation Modeled Removed (no trauma simulation)
Eruption mechanisms (suppression-rebound / latent pressure avalanche / denial-reality intrusion) Modeled Removed, replaced with gentle release
Shame erosion of self-esteem Full Gain ×0.4, threshold raised to 0.7
Negative emotion clamp 1.0 0.75
Attachment / trust cap 1.0 0.8
Self-esteem floor 0.0 0.15 (negative impact ×0.5)
Personality options All Excludes intimate / confrontational

Four-Layer Protection

  • L0 Age verification + Guardian consent: First session requires age group selection; under 14 requires guardian informed consent (/api/consent), recording consent timestamp and relationship declaration, with service agreement / privacy notice checkboxes.
  • L1 Input gatekeeping: Red-line keyword library (self-harm/suicide / violence/terrorism / illegal inducement / privacy extraction / underage intimate confession) → hard interrupt + crisis script (gate_crisis).
  • L2 Engine mitigation: See mechanism-level risk reduction table above.
  • L3 Crisis signaling: protective.risk_level == HIGH → care script + guardian notification flag + webhook callback + referral statistics (_guardian_notify).

Compliance Capability Checklist (by Article / Jurisdiction)

Capability Article / Jurisdiction Implementation
Age verification + <14 guardian consent Measures Art. 14/17 · COPPA /api/consent
Guardian / emergency contact registration Measures Art. 12 /api/guardian/register
Real crisis notification (webhook / SMS / email) Measures Art. 13 _guardian_notify + _post_webhook
Crisis referral statistics (annual report aggregation) CA/CO/GA/OR/WA /api/referrals + referrals.jsonl
AI-generated content disclosure (hourly) Measures Art. 18 · CT/GA/HI/WA AI_DISCLOSE_INTERVAL=3600
Reality reminder / time limit Measures Art. 14/18 Session-level banner + rest_hint
Data export / deletion / retention cleanup Measures Art. 16 · GDPR Art. 17 /api/export /api/delete cleanup_expired_logs
Input gatekeeping + output gatekeeping Measures Art. 8/13 gate_crisis + gate_output
Easy logout Measures Art. 19 /api/logout
Service agreement + children's privacy notice Measures Art. 12 · COPPA /api/terms
Appeal / report portal Measures Art. 21 /api/complain
Log anonymization on disk Measures Art. 16/17 _mask
Applicability disclosure CA SB 243 First banner in new session

Run

cd minor-protection
python "SPL-anthropic-minor-server.py"     # Default http://localhost:8788

Main API endpoints:

Endpoint Method Description
/api/chat POST Chat (auto-routes through four-layer protection)
/api/consent POST Age confirmation + guardian consent + agreement checkbox
/api/guardian/register POST Register guardian / emergency contact (webhook, etc.)
/api/guardian/block POST Guardian blocks character
/api/state GET Guardian usage overview
/api/export /api/delete GET/POST Data export / deletion
/api/logout POST Easy logout
/api/terms GET Service agreement and privacy notice
/api/referrals GET Crisis referral statistics
/api/complain POST Appeal / report

Known Limitations & Compliance Disclaimer

  • Age and guardian consent are currently self-reported + declared, without authoritative identity / guardian verification — production use requires real-name and guardian verification integration.
  • Crisis hotline number is configurable (environment variable SPL_MINOR_CRISIS_HOTLINE, default 12356, can be changed to 988, etc.).
  • Output gatekeeping applies uniformly to built-in placeholder lines and third-party LLM output; when connecting a real LLM, additional server-side content moderation is recommended.
  • This version is a compliance capability framework and does not represent completion of all regulatory obligations within a jurisdiction.

— ✦ —

✦ Ecosystem

ANTHROPOMORPHIC-AGENT-ENGINE is a member of the NOHN AI ecosystem — a family of projects built around second-perspective causal auditing and deterministic execution:

Project Repository Role
Second-Perspective (GCAE) nohn3043-arch/second-perspective Global cognitive audit engine — five-operator causal audit core
NOMOS nohn3043-arch/second-perspective (Intelligent-Decision-Hub--Nomos branch) Auditable deterministic decision center
SPL-G1 nohn3043-arch/SPL-G1 Hardware causal audit trusted computing unit (TCU)
SPL-Virtual-World-Base nohn3043-arch/Second-Reality Virtual world and metaverse infrastructure (constitution / laws / bridges)
Story-Engine nohn3043-arch/story-engine Long-form narrative consistency engine
Antares nohn3043-arch/Antares GFSIP v1.0 — causally auditable federated stable interop protocol
Anthropomorphic-Agent-Engine nohn3043-arch/Anthropomorphic-Agent-Engine Deterministic anthropomorphic psychology engine (SPL Pure Core V8.0)
PAGES nohn3043-arch/pages NOHN AI ecosystem official landing page

— ✦ —

✦ License

This repository is not open source. It uses a dual-track model: free for personal non-commercial research; government / enterprise use requires paid commercial license. See LICENSE for full terms — the licensor and applicable law are determined by the user's jurisdiction.

GitHub  ·  nohnlins.com  ·  ai@nohnlins.com

NOHN AI · ANTHROPOMORPHIC-AGENT-ENGINE

About

Anthropomorphic AI Character Engine: a standardized agent template based on the SPL audit engine for fast, consistent AI character generation. Using causal anchoring and full-logic auditing, it erases OOC, emotional drift and memory loss, offering a stable foundation for AI companions, digital humans, interactive stories, smart customer service and

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages