From 594bc05772512587ca12c1e32db0eab9e5993df8 Mon Sep 17 00:00:00 2001 From: Hither1 Date: Sat, 24 Oct 2026 15:59:55 -0400 Subject: [PATCH] KiCad mfm: --no-recall Removes the [RECALL] block alone, within and across tasks: no earlier turn is pushed into a turn prompt, and the memory paragraph keeps only its description of the index fields. The query tool, the situation table, the index rows and the screenshots are unchanged -- unlike --flat-retrieval, which removes the tool and the block together. CarrySink takes tool= so the note on the carried index follows the tool, not the push. The full arm is byte-identical (KiCad pins record the same). Co-Authored-By: Claude Opus 5.5 (1M context) --- CUA-KiCad/gym_codex/mfm_prompts.py | 5 +++++ CUA-KiCad/gym_codex/prolong_agent.py | 21 +++++++++++++++------ CUA-KiCad/gym_codex/run_eval.py | 12 +++++++++++- mfm/memory/carry.py | 9 ++++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CUA-KiCad/gym_codex/mfm_prompts.py b/CUA-KiCad/gym_codex/mfm_prompts.py index a781ab3..96e258d 100644 --- a/CUA-KiCad/gym_codex/mfm_prompts.py +++ b/CUA-KiCad/gym_codex/mfm_prompts.py @@ -83,6 +83,11 @@ perception and action, what followed, and the step after that. It is your own hi retrieved for this moment; if the chain matches what you intend, queue its steps as \ one plan.""" +#: RECALL_NOTE under `run_eval.py --no-recall`: the index fields it describes, without the +#: block (the rows are written and the query tool reads them as before). +RECALL_NOTE_NO_PUSH = RECALL_NOTE.split(" When the situation", 1)[0] +assert RECALL_NOTE_NO_PUSH.endswith("a perceptual hash of its frame.") + CONVENTIONS_NOTE = """\ Schematic conventions the netlist comparison is sensitive to: diff --git a/CUA-KiCad/gym_codex/prolong_agent.py b/CUA-KiCad/gym_codex/prolong_agent.py index cec9223..8e6754e 100644 --- a/CUA-KiCad/gym_codex/prolong_agent.py +++ b/CUA-KiCad/gym_codex/prolong_agent.py @@ -34,6 +34,7 @@ from gym_codex import prompts_prolong from gym_codex.actions import ParsedBatch, parse_batch from gym_codex.mfm_prompts import (CONVENTIONS_NOTE, DESIGN_EXISTING, DESIGN_NOTE, DESIGN_PROMPT, PLAN_QUEUE_NOTE, RECALL_NOTE, + RECALL_NOTE_NO_PUSH, SCREEN_MARKER, SCREEN_MARKER_NO_IMAGES, mfm_memory_note) from mfm.agent.base import MemoryAgent, Observation, Plan from mfm.backend import errors as backend_errors @@ -104,7 +105,7 @@ class ProlongGuiAgent(MemoryAgent): design: bool = False, design_effort: str = "high", conventions: bool = False, cli: str = "codex", history_images: bool = True, flat_retrieval: bool = False, - consolidation: bool = True) -> None: + consolidation: bool = True, recall_push: bool = True) -> None: # PRO-LONG (`prolong-logonly`): the record lives beside the workspace the model # works in, and `EpisodeLog.publish` takes the model's own files back every # turn (mfm/memory/log.py), so the log is the only memory. @@ -133,15 +134,21 @@ class ProlongGuiAgent(MemoryAgent): # no screenshot of an earlier turn or task is kept (the current one is still # attached); no query tool and no [RECALL]/[SEEN BEFORE] push (the rows are still # written); an earlier task's record is carried without the files the model wrote, - # `notes/` or the situation table. + # `notes/` or the situation table. `--no-recall` removes the [RECALL] push alone: + # the query tool, the situation table and every row stay. self.history_images = bool(history_images) self.flat_retrieval = bool(flat_retrieval) self.consolidation = bool(consolidation) + self.recall_push = bool(recall_push) self.ablations = (([] if self.history_images else ["no_history_images"]) + (["flat_retrieval"] if self.flat_retrieval else []) - + ([] if self.consolidation else ["no_consolidation"])) + + ([] if self.consolidation else ["no_consolidation"]) + + ([] if self.recall_push else ["no_recall"])) if self.ablations and not episodes: raise ValueError("the MFM ablations need the episode store (an mfm arm)") + if not self.recall_push and (self.flat_retrieval or not recall): + raise ValueError("recall_push=False removes the [RECALL] block: it needs an arm " + "with recall on, and flat retrieval removes the block already") if not self.consolidation and not carry_dir: raise ValueError("consolidation=False ablates what is carried across tasks: " "it needs an mfm-carry arm") @@ -156,14 +163,15 @@ class ProlongGuiAgent(MemoryAgent): # The MFM arm: the episode store beside the log, and (its one deliberate # deviation from the log arm's protocol) a # multi-batch plan drained one batch per step with the flush rules below. + push = not self.flat_retrieval and self.recall_push self.store = (EpisodeStore(record, recall=recall, tool=not self.flat_retrieval, - images=self.history_images, push=not self.flat_retrieval) + images=self.history_images, push=push) if episodes else None) self.plan_queue = plan_queue note = (mfm_memory_note(images=self.history_images, flat=self.flat_retrieval) if episodes else "") if episodes and recall and not self.flat_retrieval: - note += "\n\n" + RECALL_NOTE + note += "\n\n" + (RECALL_NOTE if self.recall_push else RECALL_NOTE_NO_PUSH) if plan_queue: note = (note + "\n\n" if note else "") + PLAN_QUEUE_NOTE.replace("{plan_cap}", str(PLAN_CAP)) self.mfm_memory_note = note or None @@ -172,7 +180,8 @@ class ProlongGuiAgent(MemoryAgent): # for prolong-carry and mfm-carry; the store is the only difference. self.carry = (CarrySink(Path(carry_dir), task_id or Path(workspace).parent.name, record, outcomes=carry_outcomes, images=self.history_images, - push=not self.flat_retrieval, consolidation=self.consolidation) + push=push, tool=not self.flat_retrieval, + consolidation=self.consolidation) if carry_dir else None) if cli == "claude": # prolong_search/claude_backend.py: CodexTurn's surface on `claude -p`, with a diff --git a/CUA-KiCad/gym_codex/run_eval.py b/CUA-KiCad/gym_codex/run_eval.py index 1714cec..9d12109 100644 --- a/CUA-KiCad/gym_codex/run_eval.py +++ b/CUA-KiCad/gym_codex/run_eval.py @@ -202,6 +202,8 @@ def _ablation_kw(args) -> dict: kw["flat_retrieval"] = True if getattr(args, "no_consolidation", False): kw["consolidation"] = False + if getattr(args, "no_recall", False): + kw["recall_push"] = False return kw @@ -494,6 +496,10 @@ async def main() -> int: "carried as the harness's record only (log, episodes, index, " "screenshots) -- no notes/ across tasks, no situation table, none " "of the files the model wrote") + abl.add_argument("--no-recall", action="store_true", + help="without the [RECALL] block: no earlier turn is pushed into a turn " + "prompt, within or across tasks; the query tool, the situation table " + "and the index are unchanged") p.add_argument("--cli", choices=("codex", "claude"), default="codex", help="which CLI carries the model: codex " "(default), or claude -- Anthropic models through Claude Code " @@ -533,6 +539,9 @@ async def main() -> int: "the mfm arms") if args.no_consolidation and args.agent != "mfm-carry": p.error("--no-consolidation ablates what is carried across tasks: it needs mfm-carry") + if args.no_recall and args.flat_retrieval: + p.error("--flat-retrieval already removes the [RECALL] block; --no-recall is the " + "block alone") logger.info("env=%s budget=%d steps", args.env_id, args.max_steps) import lite.gym as gym # after sbatch has set up PATH/PODMAN_* for the shim @@ -594,7 +603,8 @@ async def main() -> int: if _ablation_kw(args): summary["ablations"] = [n for f, n in (("no_history_images", "no_history_images"), ("flat_retrieval", "flat_retrieval"), - ("no_consolidation", "no_consolidation")) + ("no_consolidation", "no_consolidation"), + ("no_recall", "no_recall")) if getattr(args, f)] options = ARMS.get(args.agent, {}) if options: diff --git a/mfm/memory/carry.py b/mfm/memory/carry.py index 8dcbbe0..c44232b 100644 --- a/mfm/memory/carry.py +++ b/mfm/memory/carry.py @@ -258,7 +258,7 @@ def seed_previous(prev_dir: Path, records: "list[CarriedRecord]", *, class CarrySink(MemorySink): def __init__(self, root: Path | str, task_id: str, record_dir: Path | str, outcomes: bool = False, images: bool = True, push: bool = True, - consolidation: bool = True) -> None: + consolidation: bool = True, tool: bool | None = None) -> None: self.root = Path(root) self.task_id = str(task_id) self.record = Path(record_dir) @@ -273,6 +273,9 @@ class CarrySink(MemorySink): # the harness's record of an earlier task (_RECORD_ONLY), no `notes/` and no # situation table. self.images, self.push, self.consolidation = bool(images), bool(push), bool(consolidation) + # Whether the store's query tool is there (the note on the carried index names + # it); by default the push and the tool go together, as flat retrieval removes both. + self.tool = self.push if tool is None else bool(tool) self.root.mkdir(parents=True, exist_ok=True) (self.root / "notes").mkdir(exist_ok=True) self.manifest_path = self.root / "manifest.json" @@ -307,7 +310,7 @@ class CarrySink(MemorySink): note += "\n\n" + carry_outcomes_note(consolidation=self.consolidation) store = self._store(agent) if store is not None: - note += "\n\n" + (CARRY_STORE_NOTE if self.push else CARRY_STORE_NOTE_FLAT) + note += "\n\n" + (CARRY_STORE_NOTE if self.tool else CARRY_STORE_NOTE_FLAT) if store.recall: recall = carry_recall_note(push=self.push, consolidation=self.consolidation) if recall: @@ -453,7 +456,7 @@ class CarrySink(MemorySink): # outcomes must not move (tests/test_carry.py pins them). out["outcomes"] = True ablations = ([] if self.images else ["no_history_images"]) \ - + ([] if self.push else ["flat_retrieval"]) \ + + ([] if self.push else ["flat_retrieval" if not self.tool else "no_recall"]) \ + ([] if self.consolidation else ["no_consolidation"]) if ablations: out["ablations"] = ablations -- 2.43.7