← all documents · raw markdown · 5 KB

KAI Agent Core — the RSHL-native working AI

*Goal owner: Ryan. Started v9.10.557 (2026-08-02). Status: Phase 1 SHIPPED.*

The ask

> "kais Full fledge Working Ai. like how LLMs are able to work as AI i need that with all the kai layers and stuff working so he can generate all the working needed things and use tools and all that like an LLM can but hes RSHL."

The gap analysis (what "works like an LLM agent" actually decomposes into)

| Capability | LLM agents | KAI before this | Verdict |
|---|---|---|---|
| Memory / context | context window (evaporates) | lattice + WorkingMemory + GlobalWorkspace (permanent) | KAI ahead |
| Reasoning | chain-of-thought tokens | multi-hop synaptic traversal, looped reasoner, tree reasoner | present |
| Fluent generation | transformer | decode ladder (retrieval-first) + native_decode logit-steering hook; tiny transformer in training | in progress (the "mouth") |
| Tool selection | learned | keyword prefixes ("run command …") | missing — was routing, not choosing |
| Multi-step agency | ReAct loop (think→act→observe→repeat) | single-shot TurnAction | THE missing structure |
| Observation feedback | tool result → context | tool result → returned to user, forgotten | missing |
| Learning from acting | impossible (frozen weights) | lattice can store outcomes permanently | KAI's unfair advantage — was unused |

The missing piece was never another layer — it was the loop that makes the existing layers act together.

Phase 1 — the agent loop (SHIPPED, src/cognition/agent_core.rs)

RSHL-native ReAct cycle, no LLM anywhere in the control path:

GOAL
 └─► THINK    lattice retrieval for the current subtask (workspace broadcast
              re-ranks it — v9.10.556 mediation is load-bearing here)
 └─► SELECT   tool chosen by resonance: 0.3·cosine(task_vec, tool_vec) +
              0.7·keyword overlap — the house retrieval blend, applied to tools
 └─► ACT      execute (lattice_query / read_file / write_file / research_docs /
              math / shell [double-gated])
 └─► OBSERVE  result stored as a lattice cell (region "agency") — PERMANENT
              learning-from-acting — and posted to the GlobalWorkspace, so the
              next THINK step literally retrieves through what just happened
 └─► DONE?    goal↔observation resonance > threshold, or step budget exhausted
 └─► repeat (max 8 steps)

Every step is recorded as a readable AgentStep {thought, tool, input, observation, resonance} — the agent's working is inspectable the same way the silent-thought ring is (J-Space discipline: nothing the agent does is opaque).

Endpoint: POST /api/agent/run {goal, max_steps?} → full step trace + outcome. Explicit-invocation only (no autonomous trigger). Behind QueryAdmission like every lattice query.

Safety: KAI_AGENT_CORE default ON (endpoint-only). Shell tool requires both the goal to literally contain the command and KAI_AGENT_SHELL=1 — stricter than the pre-existing chat path ("run command …"), which stays unchanged. File writes stay inside the workspace sandbox dir unless KAI_AGENT_SHELL=1.

Phase 2 — the transformer mounts INTO the loop (when the tiny model is ready)

The transformer is the *mouth and the planner's polish* — never the mind:

1. Narration: native_decode (lattice-biased logits, already built) renders each step's outcome fluently instead of raw cell text.

2. Subtask decomposition: goal → ordered subtasks (today: the goal IS the subtask; the reasoner refines it).

3. Argument extraction: cleaner tool inputs than Phase 1's heuristics.

Everything else — memory, selection, observation, learning — stays lattice. A bigger model makes KAI *smoother*, never *different*.

Phase 3 — proactive agency (design sketch, not started)

The autonomic loop (engine.rs, every 300 idle ticks) already wonders/daydreams/dreams. Phase 3 lets a validated dream insight or a high-salience workspace broadcast *file its own goal* into the agent loop (rate-limited, owner-visible in the MindEvent stream, off by default: KAI_AGENT_PROACTIVE). That is the last rung between "tool that answers" and "colleague that notices."

Why this beats bolting an LLM on

An LLM agent's every run starts from amnesia; its tool use is frozen at training time. KAI's loop learns permanently from every action (agency cells wire into the lattice and future retrievals), thinks through a live workspace (yesterday's observation can re-rank today's retrieval), and shows its work natively (steps and silent thoughts are words, not activations). Slower and rougher than GPT-class today — but structurally capable of something none of them are: getting better at acting *by having acted*.