MOIM / Persistent Instructions — Architecture Reality
Goose’s MOIM (Model-Observed Internal Memory) provides persistent
instructions via GOOSE_MOIM_MESSAGE_FILE. Understanding the actual
delivery mechanism is critical for SOUL.md identity delivery.
Architecture (Source-Code Verified)
Two separate mechanisms share the “MOIM” name:
1. {{ moim_system_prompt_block }} in system.md
moim::system_prompt_block() in prompt_manager.rs returns a
hardcoded explanation template — the “# Turn Context” text that
tells the model what <turn-context> blocks are. This is always
rendered regardless of the tom extension. It has nothing to do with
instructions.md or SOUL.md.
2. tom (Top Of Mind) extension — get_moim()
The tom platform extension in platform_extensions/tom.rs reads
GOOSE_MOIM_MESSAGE_FILE (instructions.md) and returns its content
via the get_moim() MCP trait method. This content is collected by
lease.moim() in moim.rs and composed into a <turn-context>
block — a user-role message injected every turn at the
recency peak.
Key Facts
| Property | Value |
|---|---|
| Source file | ~/.config/goose/instructions.md |
| Reader | tom extension get_moim() |
| Delivery | Per-turn <turn-context> user message |
| Position | Recency peak (last content before model generates) |
| Requires | tom extension enabled: true in config.yaml and GOOSE_MOIM_MESSAGE_FILE set |
| Without tom | Content never reaches the model — zero delivery |
Without GOOSE_MOIM_MESSAGE_FILE |
Same — tom has no default file and injects nothing, even with tom enabled |
Where tom Reads the File Path (Goose 1.60.1)
tom.rs calls Config::global().get_param("GOOSE_MOIM_MESSAGE_FILE").
get_param (config/base.rs) checks the environment variable first,
then a top-level key in config.yaml. The official docs only show the
environment variable; the config key works too and is the better choice
— it applies to both CLI and Desktop without editing .desktop files or
environment.d.
# ~/.config/goose/config.yaml (top level, column 0)
GOOSE_MOIM_MESSAGE_FILE: ~/.config/goose/instructions.md
| Property | Value |
|---|---|
| Re-read | Every turn — file content and the key itself; no restart needed |
~ expansion |
Yes (shellexpand::tilde) |
| Size cap | 64 KB, UTF-8 safe truncation |
Both _TEXT and _FILE set |
Concatenated |
Gotchas
- Silent failure. Every setup check can pass (tom enabled, SOUL
section present in
instructions.md) while nothing is delivered. The only end-to-end test: does<turn-context>contain the SOUL? - Unanchored grep false positive.
grep GOOSE_MOIM_MESSAGE_FILE config.yamlmatches tom’s owndescription:line, which names the variable. Match the key at column 0:grep '^GOOSE_MOIM_MESSAGE_FILE:'. system-md-gen.sh --generateregisters the key (goose-agentfs-setup ≥ 1.10.0);--checkreports it.
What {{ moim_system_prompt_block }} Actually Is
It is NOT instructions.md content. It is a hardcoded Goose platform
text explaining what <turn-context> blocks are:
# Turn Context
Each turn may include a `<turn-context>` block added to the request.
This block is generated by goose and contains current operational context...
This renders in the system prompt (primacy zone) always, regardless of tom extension state. Moving its position in system.md has no effect on SOUL delivery.
Consequence for AgentFS
- tom extension is a hard dependency for SOUL.md delivery on Goose
- Without tom, weaker models (14B) confabulate identity principles (0/9 correct). With tom, they cite them accurately (9/9 correct)
system-md-gen.sh --generateauto-enables tom and checks its statusinstructions.mdis the source file for SOUL content. Profile switching (activate-profile.sh) overwrites the SOUL section there
Corrected From
Original version (2026-09-29) incorrectly stated MOIM injects at the
same primacy zone as AGENTS.md. Source code review (2026-11-04) of
tom.rs, moim.rs, and prompt_manager.rs confirmed tom injects
into <turn-context> per-turn user messages (recency peak).
Harvested From
| Project | Source | Entry |
|---|---|---|
| context-eng | Session: AgentFS Evolution | Source code review of Goose v1.57.0 tom.rs, moim.rs, prompt_manager.rs |
| context-eng | Session: first fresh Goose AgentFS setup (2026-11-19) | SOUL not delivered on a fresh setup; v1.60.1 tom.rs + config/base.rs review; fix verified live in <turn-context> |