Imagination: Recombining Memory Into Scenarios

Imagination recombines Episodic Memory into hypothetical scenarios, filtered through Abstraction (Requirements Spec Sec 3; Req 4.4). It is pure PatLang with no language-model call involved (Req 4.6) — the recombination itself is symbolic, not generative: it pairs two recalled episodes' raw text into a fixed template, not an LM-written synthesis of them.

"Filtered through Abstraction," concretely

Imagination pulls up to ten recent episodes from Episodic Memory (imagination_recall_episodes, via a recall signal call), then narrows that list with imagination_known_entities: for each episode, it extracts the primary entity and asks Abstraction's live categorize signal whether that entity currently resolves to anything other than "unknown". Only episodes that pass are eligible to be recombined. An episode Abstraction has no schema for yet simply cannot participate — which is the whole point: Imagination's raw material is gated by exactly the same trust-mediated category induction documented on the Abstraction page.

One further filter matters and is easy to miss: episodes whose interlocutor matches Imagination's own tag, "self_imagination", are excluded from the eligible set. The source comment explains why this was added, and it is a real bug the project found and fixed rather than a defensive habit — without it, an imagined scenario gets stored back into Episodic Memory like any other percept, ages into the recall window, and becomes eligible to be recombined again, nesting a prior scenario's own quoted text inside the next one every cycle and growing without bound. Excluding only the component's own prior output — not other real, even degenerate, past conversation — keeps Imagination recombining what actually happened.

The scenario, and its novelty score

When two eligible episodes are available, imagination_attempt builds a fixed-template scenario — What if we combined "<raw_a>" with "<raw_b>"? — and computes a novelty score for that specific pairing via imagination_novelty_for. Novelty is tracked per (entity, entity) pair ever imagined, order-independent (imagination_pairing_key sorts the two raw strings before combining them) and durable across restarts, in .patlang_queue/imagination_pairing_counts.json. The formula is deliberately narrow: novelty = 1.0 / new_count, where new_count is how many times this exact pairing has now been imagined. The first time a pairing occurs, novelty is 1.0; every repeat pushes it lower. The source comments are explicit that this is a repetition-count measure of one specific pairing, not a general semantic-similarity novelty score — an honest, narrow claim rather than a broader one the mechanism can't actually support.

features/imagination.feature checks this directly: two known episodes recombine with novelty 1 the first time; asking Imagination to imagine the same pairing again produces a strictly lower novelty; and with too few known-category episodes available, no scenario is produced at all rather than the component crashing or fabricating one.

The predicted decline, and where it's measured

The architecture document ties this mechanism to a specific, testable prediction from Requirements Spec 4.4, citing the Einstellung effect — see the evaluation page and the architecture page for the full citation and measurement method. As Abstraction accumulates more admitted examples, more episodes categorize as known, more pairings become eligible, and the same well-established pairings get recombined more often — so imagined-scenario novelty should measurably decline over time. Imagination's own job stops at producing one honest, real per-scenario novelty score each time it's asked; it does not compute or assert any trend itself.

That trend measurement is a separate harness, eval/imagination_novelty.patlang. It spawns real Abstraction, Episodic Memory and Imagination instances, runs three rounds of new-entity, same-category, trusted-interlocutor admissions, and after each round asks the live Imagination component to imagine — recording its genuine novelty score, not a simulated one. Its own header is careful about scope: because Imagination always recombines the earliest known-category pair still inside Episodic Memory's bounded ten-episode recall window, this specific harness measures repetition-based decline on that one pair as the pool grows past it, not the stronger (and different) claim that a growing pool changes which pairs are ever possible — Imagination's pairing choice is deterministic, not sampled from the whole pool, so that stronger claim isn't what this measurement can support. features/imagination_novelty_eval.feature confirms the harness runs three real rounds end to end and writes a results file with novelty non-increasing across them. The harness writes its verdict as data regardless of outcome — decline, flat, or a rise reported as the opposite of the prediction — rather than assuming the predicted direction in advance.

An idle instance imagines on its own

Beyond the on-demand imagine signal, Imagination can fire autonomously. It compares Episodic Memory's most-recently-stored raw episode against what it last saw; if that hasn't changed for at least imagination_idle_threshold_ms() (60 seconds) and at least imagination_min_fire_interval_ms() (120 seconds) has passed since it last fired, it runs the same recombination logic and, if a scenario results, injects it back into a configured Perception instance as a real percept — tagged with interlocutor "self_imagination" so trust-gating and any audit trail can always tell an imagined origin apart from a real interlocutor. The source comment records the reason this was added: a two-instance bridge conversation showed one side doing real, independent work while the idle side only ever produced passive acknowledgements of what it was told — an idle instance otherwise had nothing of its own to think about between real inputs.

See also

Imagination draws its material from Episodic Memory, filtered by Abstraction, and — when it fires autonomously — feeds results back into Perception. For the Einstellung-effect citation and the full evaluation method, see the evaluation page and the architecture page.