Skip to content

Memory and Reuse

Memory in MAGE comes in two layers. The library layer is what MAGEGenerator does and what MAESTRO runs. The v3 layer is research code; it is described at the end of this page and is not callable from the package.

Released, with stricter rules on the development line. Memory is optional: it needs the memory extra (gigaevo-client) and a running GigaEvo Memory service at memory_base_url (default http://localhost:8002). Every memory failure is logged and generation continues.

WhatSwitch (default)Notes
Recall related chains before planningenable_memory_research (off)Deep mode only. Sub-queries over current_task, search by memory_search_mode (hybrid, bm25 or vector), an applicability gate (memory_applicability_threshold, memory_min_applicable_hits), then a short digest for the step planner. With no applicable hits it is a cold start.
Recall skills from Memoryenable_memory_skill_lookup (off)Feeds capability lookup.
Save the generated chainenable_memory (on)MemoryManager.save_chain.
Save skills, reusable steps, failure cards, artifactsenable_*_save flags (off)Keys appear in MAGEResult.memory_keys.

The save is implicit and has conditions (development line):

  • the task was a plain string, or the request has PersistencePolicy(mode="safe_projection_only");
  • nothing private reached the planning prompt;
  • compile() never saves.

A saved chain carries a metadata block in content.metadata: task_description (the safe task only), context_files, generated_by="mage", mage_metadata, display_name, description. See CARL chain metadata.

Development line. MAESTRO does not let MAGE search memory on its own when IdeaL is the chain memory. Before generation it asks the IdeaL catalog for related chains, ideas and tools of the task (mode=catalog), then passes the answer to MAGE as one RetrievedUntrustedContext with id ideal-catalog under DataEgressPolicy(generation_model_context="allow_selected_retrieved_context"). In that case MAESTRO turns off enable_memory, enable_memory_research and enable_memory_skill_lookup. MAGE sees the hints as labelled data and writes nothing back: catalog reads are not recorded in IdeaL.

With the legacy GigaEvo backend MAESTRO also recalls first and passes the result as untrusted context. See MAESTRO as host and IdeaL overview.

Experimental: generation memory and the reuse ladder

Section titled “Experimental: generation memory and the reuse ladder”

Experimental, branch feat/v3-ideal-loop (merged into the 0.2.0 candidate), plugged into the v3 generator only from the MAGEBench arms in evaluation/ (mmar_mage/generation_memory.py, mmar_mage/ideal_loop.py). The shipped generation_strategy="v3" does not use it.

A task gets a profile (task families derived from the input schema, tools, output contract) and a stable task key. Two memories build on that:

Examples and ideas (memory_mode): skeletons of up to two proven chains of similar tasks, and up to three IdeaL ideas, are added to the author’s prompt; the ideas used are cited in the generation’s trace. Stores: a local JSON file or the IdeaL catalog.

Reuse ladder (memory_loop, hypothesis H1 of the memory study):

RungCondition (defaults)What happens
ExactSame task key, execution fitness ≥ 0.999The stored chain is compiled and admitted for the new contract and returned with no model call.
NearProfile similarity ≥ 0.8, fitness ≥ 0.999The stored chain is the starting draft. By default (memory_loop_near_mode: adapt) the author gets one call to check every requirement; the planner is skipped.
DemotionA reused chain later fails executionIt is never offered again.

Fitness comes from execution: after a benchmark case runs, the runner records the chain with its execution quality, in a local store or as an IdeaL run outcome.