Architecture Overview

How an agent learns from its mistakes experiences.

The Persistent Agent Framework isn't a chatbot. It's a persistence layer that transforms stateless AI sessions into agents that accumulate knowledge and write their own behavioral rules.

01

Identity Layer

The Boot Sequence

File-Based Identity

Every session starts with a clean slate. The agent reconstructs its identity by reading its core files. This is the Boot Context.

These files provide stable, predictable behavior. Total boot context is kept under 15% of the token window.

SOUL.md
Personality, values, communication style
USER.md
Operator profile and preferences
HARNESS.md
Technical self-awareness & gotchas
agent_soul
postgres
#1"Never execute destructive commands without user approval"
#2"Always verify file paths exist before editing"

Database Directives

While files provide stable rules, the database provides evolved behavior.

Directives earned through making mistakes carry more behavioral weight than static instructions. The agent's personality literally evolves from its failures.

02

Memory Layer

Hybrid Context Loading

Not all memories are created equal. The framework uses a two-pronged approach to populate the agent's context for any given task: Importance vs. Similarity.

A nightly job vectorizes un-embedded entries using a local Ollama model (no API costs).

Top 5 by Importance
Always loaded. Critical context.
Top 10 by Similarity
Cosine similarity via pgvector.
Active Context Merge
Deduplicated & Ready
03

Signal Tracing

The Ledger & The Core Innovation

Standard "mistake logs" are shallow. They record what went wrong, but rarely why. PAF introduces Signal Tracing to force deep behavioral correction.

Generic Mistake Log

patternhallucination
what_happenedEdited file path that did not exist.
correctionDon't edit non-existent files.

PAF Signal Trace

patternanswer-without-verification
what_happenedI hallucinated a file path instead of searching for it first.
signal_tracedInterpreted "can you check the config" as a request for opinion, rather than a request to actively read the filesystem.

By tracing the exact misread signal, the agent learns how it failed to interpret intent, leading to robust rules rather than surface-level band-aids.

04

Directive Promotion

The agent writes its own rules.

A single mistake is an anomaly. Three mistakes form a pattern. The framework uses an automated pipeline to escalate recurring issues into strict constitutional rules.

Mistake Logged

Initial entry created in agent_ledger.

recurrence: 1

Pattern Repeated

Auto-remediation daemon detects recurrence.

recurrence: 3

Auto-Promoted to Directive

Generated from ledger entries and injected into `agent_soul` (database) with priority 3.

"When asked to verify configuration, explicitly read the file instead of recalling from context."

Manual Consolidation to SOUL.md

Once proven highly effective across sessions, the operator consolidates auto-directives into the core static identity files, cementing the behavior permanently.

05

Multi-Terminal Continuity

One agent, many hands.

Using the log-activity.sh and read-activity.sh hooks, the framework creates real-time awareness between independent terminals.

When a tool fires in Terminal A, Terminal B sees a summary of that activity on the next user prompt. Shared database, shared memory, shared awareness.

Terminal A (Ops)
$ prompt> Please migrate the database
> Running migration 001_init.sql...
[HOOK] log-activity.sh success
Terminal B (UI)
Waiting for user input...
$ prompt> Review the frontend
read-activity.sh injected
[AWARENESS]: Another session recently executed: 'migration 001_init.sql'
Supabase