toolnexus.agents.home/from-dir
Clojure (JVM) + cljgo · package net.clojars.muthuishere/toolnexus · SPEC §7E · clojure/src/toolnexus/agents/home.cljc
(home/from-dir dir)(home/from-dir dir {:name "…" ; default: the directory's last segment :does "…" ; default "persona agent from <dir>" :model "…" ; default "inherit" :tools [...] ; extra tools, placed BEFORE the memory tool :memory false ; omit the memory tool (read-only persona) :memory-index-cap true ; or {:max-lines n :max-bytes n}; off by default :notes true ; notes tier of the memory tool; off by default :dream {:every-ms ms :store store :instructions "…"}});; => an AgentDef mapThe directory is the agent. from-dir runs compose-soul
over dir once, so the soul is a frozen snapshot for the whole run, and wires a
memory-tool over the same directory unless :memory false.
The return value is a plain AgentDef map — this port’s spelling of a §7D agent. Put it in a
runtime’s :registry and rt/run-agent / rt/agent-tool work on it unchanged, or hand it to
home/start-agent for a heartbeat.
When to use it
Section titled “When to use it”Whenever a persona’s identity lives in files — SOUL.md, AGENTS.md, USER.md, MEMORY.md and
the rest of the bootstrap set — and you want one call that turns that folder into a runnable
agent with durable memory already wired. An operator adds a persona by creating a folder; no
code change.
Why this and not the alternative
Section titled “Why this and not the alternative”Examples
Section titled “Examples”1. The smallest useful call — a directory becomes an agent
Section titled “1. The smallest useful call — a directory becomes an agent”(require '[toolnexus.agents.home :as home])
(def ava (home/from-dir "./personas/ava"))
(:name ava) ;; => "ava"(:model ava) ;; => "inherit"(mapv :name (:tools ava)) ;; => ["memory"]2. The realistic case — run it on a runtime
Section titled “2. The realistic case — run it on a runtime”(require '[toolnexus.agents.home :as home] '[toolnexus.agents.runtime :as rt])
(def support (home/from-dir "./personas/support" {:name "support" :does "answers support questions"}))
(def runtime (rt/create-runtime {:registry {"support" support} :llm llm}))(println (:text (rt/run-agent runtime "support" "hello there")))3. The full surface — capped index, notes, and nightly dreaming
Section titled “3. The full surface — capped index, notes, and nightly dreaming”(require '[toolnexus.agents.home :as home] '[toolnexus.client :as client])
(def store (client/file-store "./data/conversations"))
(def ava (home/from-dir "./personas/ava" {:memory-index-cap {:max-lines 120} ; :max-bytes takes the preset's 25600 :notes true :dream {:every-ms (* 24 60 60000) :store store}}))
(def started (home/start-agent ava {:llm llm} {:every-ms (* 30 60000)}));; ... "ava-dreamer" runs on the same runtime; ((:stop started)) stops bothOptions
Section titled “Options”| Option | Default | What it does |
|---|---|---|
:name |
the directory’s last segment | Agent name. |
:does |
"persona agent from <dir>" |
Routing description a delegating model sees. |
:model |
"inherit" |
Model id; "inherit" uses the runtime’s :llm model. |
:tools |
[] |
Extra tools, placed before the memory tool. |
:memory |
on | false omits the memory tool — a read-only persona. |
:memory-index-cap |
off | Cap the injected MEMORY.md: true ⇒ memory-index-cap-preset (200 lines / 25600 bytes); a map {:max-lines :max-bytes} takes the preset for a missing key; a value < 1 or non-integer throws. |
:notes |
off | true wires (memory-tool dir {:notes true}) — the notes tier. |
:dream |
off | {:every-ms :store :instructions} — dream on a schedule once started with start-agent. |
Memory hierarchy and dreaming (opt-in)
Section titled “Memory hierarchy and dreaming (opt-in)”Three options, all off by default — absent, the soul, the memory tool and the files on disk are
byte-identical to the plain call (SPEC §7E “Memory hierarchy” and “Dreaming”).
:memory-index-capcaps theMEMORY.mdindex injected into the soul at whole lines. Over the cap, the kept lines are followed by a one-line notice telling the persona to keep the index short; the file on disk is never touched, andUSER.mdis not capped.:notes trueturns on the notes tier of the wired memory tool: targetnote:<slug>writesmemory/<slug>.md, plusreadandlistactions. Notes are never injected — the persona reads them on demand and points to them from the index.:dreamschedules a dreamer over the same directory. Only when the persona is started withstart-agentdoes a<name>-dreameragent get registered on the same runtime with its own heartbeat; stopping the persona stops both.rt/run-agent/rt/agent-toolnever dream.:storeis the conversation store whose transcripts the dreamer checks memory against;:instructionsis host prose appended afterdream-prompt. A:every-ms<= 0throwsfromDir: dream.everyMs must be > 0.
See also
Section titled “See also”compose-soul— Build a persona’s system prompt from its home directory: identity, memory, skills.memory-tool— The opt-in built-in that lets a persona write durable notes to its own home.dreamer— The preset:dreambuilds.