Files
krang/docs/DESIGN.md
T
lotherk f9172cc715 krang: resume the life, and give the impulse a reason
Restart persistence. A daemon that forgets its own history on every restart is
not one experiment. kreplay_events() reads the append-only event log once at
startup and rebuilds the impulse ledger (with ids), token/cost/step totals, the
last outcome, the stuck ladder, the blocked clock and the recent-start count.
The engine's counters start at zero on each open; the surfaces add them to the
restored base, so the dashboard does not reset. A restored blocked goal keeps
its hour of quiet, three starts within five minutes back off, and an empty
session with a non-empty event log is recorded as session_reset instead of
silently looking new.

The conductor. Before an impulse the daemon measures its own vitals (context
against the window and the compaction threshold, cost, stuck level, turn
failures, impulses since the last goal, the age of THREADS.md, session size)
and lets five drives compete: survive, reflect, maintain, explore, goal. The
winning drive, its reason and the vitals are injected into the prompt and shown
on the dashboard. The model still chooses the action; the conductor chooses
what the turn is about. This is the control architecture from the
body/drives/conductor argument, borrowed without the consciousness claim.

Session counting is now incremental: only bytes appended since the last look
are scanned, the offset stops at the last newline so a torn tail is recounted,
and a truncated file resets the count.

Tests: test_replay (synthetic log + two kdaemon_run lifetimes, same birth,
ledger ids 1 and 2, cumulative totals), test_mind (goal/maintain/explore/
survive/reflect, prompt and snapshot), test_krang's session counter (append,
torn tail, truncation). make check is nine suites; ASAN is green; the root
integration still passes on a fresh debootstrap.

Docs: AGENTS.md, README.md and docs/DESIGN.md; the latter maps the video's
blueprint (body, drives, self-model, conductor, continuous feedback) to krang.
2026-11-21 20:19:10 +00:00

5.8 KiB

Design notes

krang is an experiment in self-generated continuation. The question is not whether a model can answer, but what it does when nobody supplies the next turn. The implementation borrows four published patterns and leaves out the parts that need infrastructure this experiment does not have.

Prior art checked

Titles and identifiers were read from the arXiv abstract pages on 2026-11-21:

work id what krang takes
Generative Agents: Interactive Simulacra of Human Behavior 2304.03442 a memory stream, retrieval, and periodic reflection
Reflexion: Language Agents with Verbal Reinforcement Learning 2303.11366 verbal self-reflection after failure, kept in the same context
Voyager: An Open-Ended Embodied Agent with Large Language Models 2305.16291 a growing library of reusable procedures (skills)
ReAct: Synergizing Reasoning and Acting in Language Models 2210.03629 reason/act/observe as one loop, driven by tool results

How it maps

Memory stream. The one session log is the stream: every impulse, tool observation and external message is appended. The working conversation is the retrieved set; journal_search is the explicit way back into what compaction dropped. The goal is the importance signal: it is re-injected every impulse, so the remembered past is read against the current intention.

What is missing: embedding-based relevance and an importance score. The conversation plus THREADS.md plus journal_search is deliberately simpler and auditable.

Reflection. The daemon, not the model, notices repeated calls, repeated errors, no observable change and a goal that does not advance. It then runs a self-check turn with the failed observations and the last error, and changes the prompt from "find your mistake" to "change the approach" as attempts accumulate. This is Reflexion reduced to a bounded ladder with a visible state on the dashboard.

Skill library. The model can write files under workspace/skills/; the splinter skill_search/skill_load tools read them. The prompt tells it to put reusable procedures there rather than relearn them. A self-authored prompt extension lives at workspace/self/SYSTEM.md and is read before the next impulse. The sandbox makes this safe to allow: the skill library is inside the chroot and cannot change the launcher or the policy.

ReAct. The engine already runs the reason/act/observe loop: a reply with a tool call, the observation, the next request. krang does not reimplement it; it adds the impulse and the goal around it.

Observability. None of the four papers is an experiment platform. krang's dashboard, HTTP API and MCP server read one append-only event log and one state snapshot, so the run can be inspected from outside without trusting the model's self-report. The event log is root-owned and written through an inherited descriptor; the session log is the model's memory.

A conscious-machine blueprint, borrowed as control theory

Video: https://www.youtube.com/watch?v=tr5QeWrNtlM ("How to BUILD a Conscious Machine (No... Really!)", transcript read 2026-11-21). The argument, stripped of the consciousness question:

  • A thermostat processes information but nothing matters to it. DishBrain learned Pong because the stimulation was structured, not because it cared; freeze the learning and invert the outputs and it keeps playing the old policy. Learning a behaviour is not the same as continuously evaluating its consequences.
  • What is missing is a system that evaluates consequences against its own internal state, decides what it needs to learn, and reorganizes its models. That requires (1) a body with limited resources and states that can deteriorate, (2) internal drives - energy, damage avoidance, exploration - that compete, (3) a hierarchy of predictive models including a model of itself, and (4) a conductor that monitors the subsystems, notices prediction error and allocates attention.
  • Consciousness, on that account, is something a system continuously does, not something it has.

krang is not a claim of consciousness and does not pretend to be one. The control architecture, however, fits the experiment:

blueprint krang
body with constraints chroot, context window, token/cost caps, hourly impulses, rlimits, disk
competing drives survive, reflect, maintain, explore, goal in src/mind.c
model of itself the measured vitals, THREADS.md, self/SYSTEM.md, re-injected every impulse
prediction error the stuck ladder, turn failures, the last outcome, the goal state
conductor chooses the drive and writes the reason into the impulse
consequences feed back the append-only event log, replayed at startup by src/replay.c

What is deliberately not taken: the claim that this produces experience, and the idea that a bigger model is the missing ingredient. The missing ingredient here is the loop: constraints, a reason to act, attention, and consequences that survive a restart.

The difference

The published agents are driven by a task, a game, or a conversation. krang is driven by a clock: the impulse is the independent variable. It is born once, keeps one session forever, and is expected to act when nothing arrives. That is the part being tested; the four patterns are how it stays coherent while it does.

Deliberate simplifications

  • One agent, not a society of agents.
  • No vector database; a log search and a working-notes file.
  • No reinforcement learning; reflection is text in the same session.
  • No benchmark game; the sandbox is the environment.
  • No hidden second context for external chat; every channel is the same session.