From 4410fbfa3cceb6320ea4be96641c892fd30857a0 Mon Sep 17 00:00:00 2001 From: HugoXK Date: Wed, 25 Nov 2026 03:30:22 +0000 Subject: [PATCH 1/3] test(bench): pin the matrix import against a read-only cache (#1260) Importing bench.candidate_methods builds every port, and a build loads a dataset, so the module's own --help needed a writable cache. These rows run a fresh interpreter with cache_path raising OSError(30), switch off the suite's bundled-sample shortcut so the real path is taken, and pin the whole table so a lazier one cannot silently drop a port. --- tests/test_bench_import_cost.py | 164 ++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 tests/test_bench_import_cost.py diff --git a/tests/test_bench_import_cost.py b/tests/test_bench_import_cost.py new file mode 100644 index 00000000..1462a043 --- /dev/null +++ b/tests/test_bench_import_cost.py @@ -0,0 +1,164 @@ +"""Importing the candidate-method matrix must not build a port (#1260). + +``bench/candidate_methods.py`` learns each port's ``name`` and its reserved +proposal-call count by calling ``build(0)``, and ``build`` loads a dataset. So +the matrix's own ``--help`` needed a writable dataset cache -- and, on a clean +cache, a download -- before it could print ``usage:``. + +The table is metadata, not an observation: it belongs to the module that +declares the port, so importing the matrix has to work on a host whose cache is +read-only. These tests run in a fresh interpreter with ``cache_path`` raising +``OSError(30)``, and pin the whole table so a lazily-built one cannot quietly +drop a port or change a fidelity string. +""" + +from __future__ import annotations + +import json +import os +import subprocess +import sys +import textwrap +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + +#: ``(name, fidelity)`` for every port in the matrix, as declared by the ports +#: at the commit that fixed #1260. Pinned whole: "the import works" is not the +#: same claim as "the matrix still has all fourteen ports". +PORTS = ( + ("absolute_zero", "inference_analogue"), + ("aflow", "mechanism_microport"), + ("agent0", "inference_analogue"), + ("dynamic_cheatsheet", "mechanism_microport"), + ("godel_agent", "self_edit_analogue"), + ("gskill", "mechanism_microport"), + ("promptbreeder", "mechanism_microport"), + ("r_zero", "inference_analogue"), + ("reflexion", "mechanism_microport"), + ("self_refine", "mechanism_microport"), + ("sica", "self_edit_analogue"), + ("skillweaver", "environment_analogue"), + ("textgrad", "mechanism_microport"), + ("voyager", "environment_analogue"), +) + +#: Reserved proposal calls per candidate, as declared by each port. Two for the +#: ports whose proposal is two model calls; one everywhere else. +PROPOSAL_CALLS = { + "promptbreeder": 2, + "aflow": 2, + "r_zero": 2, + "textgrad": 2, +} + +#: The host this test stands in for: a read-only ``~/.cache``. Every dataset +#: read funnels through ``cache_path``, so patching it before the matrix is +#: imported is the narrowest version of that host -- any dataset load raises. +NO_CACHE = textwrap.dedent( + """ + import agentdescent.dataloader as dataloader + + def _read_only(*args, **kwargs): + raise OSError(30, "Read-only file system") + + dataloader.cache_path = _read_only + """ +) + + +def run(body: str) -> subprocess.CompletedProcess: + """Run ``body`` in a fresh interpreter that cannot write a dataset cache. + + ``tests/conftest.py`` turns on the bundled GSM8K sample for the suite, and + that switch returns before the cache -- so it has to go, or every row here + would pass without the dataset path being reached at all. Without it the + child takes the path a reader's ``--help`` takes. + """ + env = dict(os.environ) + env.pop("AGENTDESCENT_GSM8K_SAMPLE", None) + script = NO_CACHE + textwrap.dedent(body) + return subprocess.run( + [sys.executable, "-c", script], + cwd=ROOT, + env=env, + capture_output=True, + text=True, + timeout=600, + ) + + +def test_the_name_table_imports_without_a_dataset_cache(): + proc = run( + """ + import json + + import bench.candidate_methods as matrix + + print(json.dumps(sorted(matrix.ALGORITHMS))) + """ + ) + assert proc.returncode == 0, proc.stdout + proc.stderr + assert json.loads(proc.stdout) == [name for name, _ in PORTS] + + +def test_the_fidelity_strings_still_come_from_the_ports(): + proc = run( + """ + import json + + import bench.candidate_methods as matrix + + print(json.dumps( + {name: fidelity for name, (fidelity, _) in matrix.ALGORITHMS.items()} + )) + """ + ) + assert proc.returncode == 0, proc.stdout + proc.stderr + assert json.loads(proc.stdout) == dict(PORTS) + + +def test_the_reserved_proposal_calls_match_every_port(): + proc = run( + """ + import json + + from bench.candidate_methods import PROPOSAL_CALLS_PER_CANDIDATE as calls + + print(json.dumps(calls)) + """ + ) + assert proc.returncode == 0, proc.stdout + proc.stderr + assert json.loads(proc.stdout) == { + name: PROPOSAL_CALLS.get(name, 1) for name, _ in PORTS + } + + +def test_help_prints_usage_without_a_dataset_cache(): + proc = run( + """ + import runpy + import sys + + sys.argv = ["bench.candidate_methods", "--help"] + runpy.run_module("bench.candidate_methods", run_name="__main__") + """ + ) + assert proc.returncode == 0, proc.stdout + proc.stderr + assert proc.stdout.startswith("usage: "), proc.stdout + + +def test_the_stub_cache_is_actually_read_only(): + """The control: a hostile cache that does not bite would make the rest moot.""" + proc = run( + """ + import agentdescent.dataloader as dataloader + + try: + dataloader.cache_path("gsm8k", "train.jsonl") + except OSError as exc: + print("raised", exc.errno) + """ + ) + assert proc.returncode == 0, proc.stdout + proc.stderr + assert proc.stdout.strip() == "raised 30" From d1ff29ded6c6722e648ec73a1c1684fd54d7f77a Mon Sep 17 00:00:00 2001 From: HugoXK Date: Wed, 25 Nov 2026 03:30:22 +0000 Subject: [PATCH 2/3] fix(bench): list the ports without building them (#1260) ALGORITHMS called build(0) for each port only to learn its name, and build loads that port's dataset; the matrix's own --help therefore needed a writable cache and a download on a clean one. Each port now publishes NAME and PROPOSAL_CALLS beside FIDELITY, and the table reads those. build(seed) is unchanged and still the only path that loads data. --- bench/candidate_methods.py | 9 ++++++--- changelog.d/1260-bench-import-cost.md | 6 ++++++ examples/absolute_zero/absolute_zero_selfplay.py | 9 +++++++-- examples/aflow/aflow_workflow_search.py | 9 +++++++-- examples/agent0/agent0_tool_curriculum.py | 9 +++++++-- .../dynamic_cheatsheet/dynamic_cheatsheet_cumulative.py | 9 +++++++-- examples/godel_agent/godel_agent_self_modify.py | 9 +++++++-- examples/gskill/gskill_repo_skill.py | 9 +++++++-- examples/promptbreeder/promptbreeder_genetic_prompts.py | 9 +++++++-- examples/r_zero/r_zero_challenger_solver.py | 9 +++++++-- examples/reflexion/reflexion_episodic_memory.py | 9 +++++++-- examples/self_refine/self_refine_feedback_loop.py | 9 +++++++-- examples/sica/sica_self_edit.py | 9 +++++++-- examples/skillweaver/skillweaver_web_apis.py | 9 +++++++-- examples/textgrad/textgrad_prompt_optimization.py | 9 +++++++-- examples/voyager/voyager_skill_library.py | 9 +++++++-- 16 files changed, 110 insertions(+), 31 deletions(-) create mode 100644 changelog.d/1260-bench-import-cost.md diff --git a/bench/candidate_methods.py b/bench/candidate_methods.py index 620e2517..31aba773 100644 --- a/bench/candidate_methods.py +++ b/bench/candidate_methods.py @@ -64,13 +64,16 @@ textgrad_prompt_optimization, ) +#: Every port publishes its identity, fidelity and reserved proposal calls as +#: module metadata, so the table below is built from constants: calling +#: ``build(0)`` here would load each port's dataset just to learn its name, and +#: that made this module's own ``--help`` need a writable cache (#1260). ALGORITHMS: Dict[str, Tuple[str, PolicyBuilder]] = { - module.build(0).name: (module.FIDELITY, module.build) for module in _MODULES + module.NAME: (module.FIDELITY, module.build) for module in _MODULES } PROPOSAL_CALLS_PER_CANDIDATE = { - name: builder(0).proposal_calls_per_candidate - for name, (_, builder) in ALGORITHMS.items() + module.NAME: module.PROPOSAL_CALLS for module in _MODULES } DEFAULT_OUTPUT = Path("bench/results/candidate-methods-framework-live.json") diff --git a/changelog.d/1260-bench-import-cost.md b/changelog.d/1260-bench-import-cost.md new file mode 100644 index 00000000..e3df4f51 --- /dev/null +++ b/changelog.d/1260-bench-import-cost.md @@ -0,0 +1,6 @@ +Fixed +`python -m bench.candidate_methods --help` no longer loads every port's dataset +before it can print usage: the matrix reads each port's name, fidelity and +reserved proposal calls from module constants instead of building a policy at +import time, so the command works on a host whose dataset cache is read-only and +needs no download on a clean one (#1260). diff --git a/examples/absolute_zero/absolute_zero_selfplay.py b/examples/absolute_zero/absolute_zero_selfplay.py index c345fe9a..aaf62033 100644 --- a/examples/absolute_zero/absolute_zero_selfplay.py +++ b/examples/absolute_zero/absolute_zero_selfplay.py @@ -32,6 +32,11 @@ FIDELITY = "inference_analogue" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "absolute_zero" +PROPOSAL_CALLS = 1 + _FALLBACK = CartTask((125, 240), (1, 2)) @@ -106,7 +111,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = selfplay_splits(seed, "absolute_zero") return MethodPolicy( - name="absolute_zero", + name=NAME, fidelity=FIDELITY, notes=( "Proposer, solver, grounded verifier, and zero-data curriculum are preserved in training rollouts.", @@ -123,7 +128,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=mixed_reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, reflective=True, ) diff --git a/examples/aflow/aflow_workflow_search.py b/examples/aflow/aflow_workflow_search.py index c3487bf3..b58e33cd 100644 --- a/examples/aflow/aflow_workflow_search.py +++ b/examples/aflow/aflow_workflow_search.py @@ -52,6 +52,11 @@ FIDELITY = "mechanism_microport" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "aflow" +PROPOSAL_CALLS = 2 + REVIEW_INSTRUCTION = "Check the arithmetic and return only the corrected answer." #: `select_round` computes `scores = [item["score"] * 100 ...]` before the @@ -210,7 +215,7 @@ def _modification(raw: str) -> str: train, held_out, test = gsm8k_splits(seed) return MethodPolicy( - name="aflow", + name=NAME, fidelity=FIDELITY, notes=( "The pinned revision's soft mixed selection (not UCT) runs through the population aggregator over the archive of committed workflows, with upstream's own alpha=0.2, lambda=0.3 and its score-by-100 scaling -- without which the distribution is uniform.", @@ -232,7 +237,7 @@ def _modification(raw: str) -> str: solve=solve, propose=propose, reward=gsm8k_reward, - proposal_calls_per_candidate=2, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies(selection=SoftMixed(seed=seed)), reflective=True, ) diff --git a/examples/agent0/agent0_tool_curriculum.py b/examples/agent0/agent0_tool_curriculum.py index a7cf9650..f1353d88 100644 --- a/examples/agent0/agent0_tool_curriculum.py +++ b/examples/agent0/agent0_tool_curriculum.py @@ -34,6 +34,11 @@ FIDELITY = "inference_analogue" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "agent0" +PROPOSAL_CALLS = 1 + _FALLBACK = CartTask((125, 240), (1, 2)) #: Executor samples per generated task. `generate_results` is the same @@ -174,7 +179,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = selfplay_splits(seed, "agent0") return MethodPolicy( - name="agent0", + name=NAME, fidelity=FIDELITY, notes=( "Curriculum/Executor co-evolution and multi-turn calculator use are preserved; frozen evaluation carts also run the tool loop.", @@ -190,7 +195,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=mixed_reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies(task_sampler=DifficultyWeighted()), reflective=True, ) diff --git a/examples/dynamic_cheatsheet/dynamic_cheatsheet_cumulative.py b/examples/dynamic_cheatsheet/dynamic_cheatsheet_cumulative.py index 7d84bc66..e5cd3765 100644 --- a/examples/dynamic_cheatsheet/dynamic_cheatsheet_cumulative.py +++ b/examples/dynamic_cheatsheet/dynamic_cheatsheet_cumulative.py @@ -81,6 +81,11 @@ FIDELITY = "mechanism_microport" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "dynamic_cheatsheet" +PROPOSAL_CALLS = 1 + #: Upstream's initial cheatsheet (``cheatsheet = "(empty)"`` in run_benchmark.py). INITIAL_CHEATSHEET = "(empty)" @@ -326,7 +331,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = game24_splits(seed) return MethodPolicy( - name="dynamic_cheatsheet", + name=NAME, fidelity=FIDELITY, notes=( "DC-Cu (cumulative, no retrieval) traced at suzgunmirac/dynamic-cheatsheet@5cfe3c3: Gen answers with the current cheatsheet in context, Cur rewrites the whole cheatsheet from (memory, question, the model's own answer).", @@ -349,7 +354,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=game24_reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies() if gated else Policies(acceptance=CommitEveryUpdate()), reflective=True, # Skill-layer context, like ACE's playbook. Above 0.3 the runtime audits diff --git a/examples/godel_agent/godel_agent_self_modify.py b/examples/godel_agent/godel_agent_self_modify.py index 8267bcd9..944f004f 100644 --- a/examples/godel_agent/godel_agent_self_modify.py +++ b/examples/godel_agent/godel_agent_self_modify.py @@ -30,6 +30,11 @@ FIDELITY = "self_edit_analogue" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "godel_agent" +PROPOSAL_CALLS = 1 + GODEL_INITIAL_SOURCE = '''def solve_prompt(question): return "Solve the arithmetic problem carefully. Return only the final answer.\\n\\n" + question @@ -83,7 +88,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = gsmhard_splits(seed) return MethodPolicy( - name="godel_agent", + name=NAME, fidelity=FIDELITY, notes=( "The artifact owns both solve and self-improvement prompt functions; each proposal is produced by the artifact's own current self-improvement prompt.", @@ -99,7 +104,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=gsmhard_reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=(Policies(acceptance=AcceptAnyCompiling()) if gateless else Policies()), reflective=True, diff --git a/examples/gskill/gskill_repo_skill.py b/examples/gskill/gskill_repo_skill.py index 876e8f1a..0b9d3479 100644 --- a/examples/gskill/gskill_repo_skill.py +++ b/examples/gskill/gskill_repo_skill.py @@ -71,6 +71,11 @@ FIDELITY = "mechanism_microport" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "gskill" +PROPOSAL_CALLS = 1 + SKILL_NAME = "kvtools-fixer" #: "GEPA starts with empty skills" -- as a *valid* skill, so the structural gate @@ -307,7 +312,7 @@ def report() -> str: train, held_out, test = gskill_splits(seed) return MethodPolicy( - name="gskill", + name=NAME, fidelity=FIDELITY, notes=( "Traced gepa-ai/gepa@f1cfdee src/gepa/gskill: optimize_anything evolves one repository skill from agent traces and test feedback; skills start empty and are deployed unchanged.", @@ -325,7 +330,7 @@ def report() -> str: solve=solve, propose=propose, reward=reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies(acceptance=StrictHeldOutGate()), # `ReflectiveFusion` writes its synthesis to the ledger without passing # `to_diff`, so a model-merged SKILL.md would bypass the frontmatter gate. diff --git a/examples/promptbreeder/promptbreeder_genetic_prompts.py b/examples/promptbreeder/promptbreeder_genetic_prompts.py index ccd63955..d2fcdf11 100644 --- a/examples/promptbreeder/promptbreeder_genetic_prompts.py +++ b/examples/promptbreeder/promptbreeder_genetic_prompts.py @@ -61,6 +61,11 @@ FIDELITY = "mechanism_microport" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "promptbreeder" +PROPOSAL_CALLS = 2 + MUTATION_PROMPT = MUTATION_PROMPTS[0] #: Units in the population. The paper uses 50; this is budget-sized, and the @@ -207,7 +212,7 @@ def report() -> str: train, held_out, test = gsm8k_splits(seed) return MethodPolicy( - name="promptbreeder", + name=NAME, fidelity=FIDELITY, notes=( "Algorithm 1 as written: fixed-size population, binary tournament on a random training batch, and the loser replaced by the mutated winner.", @@ -229,7 +234,7 @@ def report() -> str: # Two, not one: the paper's hypermutation operators are two model calls, # and declaring one would make the budget check fail on a run that spent # exactly what the algorithm asks for. - proposal_calls_per_candidate=2, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies(selection=BinaryTournament(seed)), reflective=True, population=population, diff --git a/examples/r_zero/r_zero_challenger_solver.py b/examples/r_zero/r_zero_challenger_solver.py index ef2e2658..4ec348ba 100644 --- a/examples/r_zero/r_zero_challenger_solver.py +++ b/examples/r_zero/r_zero_challenger_solver.py @@ -36,6 +36,11 @@ FIDELITY = "inference_analogue" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "r_zero" +PROPOSAL_CALLS = 2 + _FALLBACK = CartTask((125, 240), (1, 2)) CHALLENGER_SEED = "Increase curriculum difficulty gradually." @@ -116,7 +121,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = selfplay_splits(seed, "r_zero") return MethodPolicy( - name="r_zero", + name=NAME, fidelity=FIDELITY, notes=( "Separate Challenger and Solver role memories receive separate updates and union-merge across fields.", @@ -135,7 +140,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=mixed_reward, - proposal_calls_per_candidate=2, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies( task_sampler=DifficultyWeighted(), acceptance=AdvantageAcceptance(), # wraps the run's own gate diff --git a/examples/reflexion/reflexion_episodic_memory.py b/examples/reflexion/reflexion_episodic_memory.py index c4104e28..78b99d3f 100644 --- a/examples/reflexion/reflexion_episodic_memory.py +++ b/examples/reflexion/reflexion_episodic_memory.py @@ -56,6 +56,11 @@ FIDELITY = "mechanism_microport" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "reflexion" +PROPOSAL_CALLS = 1 + #: `prompts.REFLECTION_HEADER`, with "question" generalised to "problem" because #: this memory is shared across the domain rather than bound to one instance. MEMORY_HEADER = ( @@ -206,7 +211,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = gsmhard_splits(seed) return MethodPolicy( - name="reflexion", + name=NAME, fidelity=FIDELITY, notes=( "The reflection query carries two worked examples of a failed attempt and its plan, as _generate_reflection_query prepends FEW_SHOT_EXAMPLES; without them the reflector answers the arithmetic instead of planning.", @@ -226,7 +231,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=gsmhard_reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, reflective=True, ) diff --git a/examples/self_refine/self_refine_feedback_loop.py b/examples/self_refine/self_refine_feedback_loop.py index c2398b16..a589b439 100644 --- a/examples/self_refine/self_refine_feedback_loop.py +++ b/examples/self_refine/self_refine_feedback_loop.py @@ -47,6 +47,11 @@ FIDELITY = "mechanism_microport" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "self_refine" +PROPOSAL_CALLS = 1 + STOP_SIGNAL = "it is correct" #: `entire_output.split("def solution():")` -- the marker that separates the @@ -142,7 +147,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = gsm8k_splits(seed) return MethodPolicy( - name="self_refine", + name=NAME, fidelity=FIDELITY, notes=( "FEEDBACK and REFINE are one model call split on a marker, as GSMFeedback.__call__ is; six of the seven upstream tasks separate them, and gsm -- this port's domain -- does not.", @@ -161,7 +166,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=gsm8k_reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, reflective=True, ) diff --git a/examples/sica/sica_self_edit.py b/examples/sica/sica_self_edit.py index e90d9787..00992a64 100644 --- a/examples/sica/sica_self_edit.py +++ b/examples/sica/sica_self_edit.py @@ -43,6 +43,11 @@ FIDELITY = "self_edit_analogue" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "sica" +PROPOSAL_CALLS = 1 + SICA_INITIAL_SOURCE = '''def agent_prompt(question): return "Solve the arithmetic problem carefully. Return only the final answer.\\n\\n" + question ''' @@ -120,7 +125,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = gsmhard_splits(seed) return MethodPolicy( - name="sica", + name=NAME, fidelity=FIDELITY, notes=( "The meta loop edits real Python policy source and the framework gate measures utility.", @@ -136,7 +141,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=gsmhard_reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies(selection=Archive(sampling="best", seed=seed)), reflective=True, ) diff --git a/examples/skillweaver/skillweaver_web_apis.py b/examples/skillweaver/skillweaver_web_apis.py index 6c33fba4..df92f18a 100644 --- a/examples/skillweaver/skillweaver_web_apis.py +++ b/examples/skillweaver/skillweaver_web_apis.py @@ -48,6 +48,11 @@ FIDELITY = "environment_analogue" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "skillweaver" +PROPOSAL_CALLS = 1 + #: 48, not 12: `run_port` refuses a run whose train split is smaller than #: the worker count, so twelve tasks split 4/4/4 capped this port at four #: workers with a four-task gate. @@ -282,7 +287,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = _split(seed) categories = ["api generic"] + sorted({f"api {p}" for p, _, _ in PAGES}) return MethodPolicy( - name="skillweaver", + name=NAME, fidelity=FIDELITY, notes=( "The paper's three stages map to: Proposal = task pool + difficulty sampling; Synthesis = rollout + self-verify reward model; Honing = the repair call.", @@ -308,7 +313,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies(task_sampler=DifficultyWeighted()), reflective=False, self_verify=True, diff --git a/examples/textgrad/textgrad_prompt_optimization.py b/examples/textgrad/textgrad_prompt_optimization.py index 67c06f5d..6aec6bad 100644 --- a/examples/textgrad/textgrad_prompt_optimization.py +++ b/examples/textgrad/textgrad_prompt_optimization.py @@ -82,6 +82,11 @@ FIDELITY = "mechanism_microport" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "textgrad" +PROPOSAL_CALLS = 2 + UPSTREAM = "zou-group/textgrad@75e912e210864b61999781778cdf756d4468120f" #: ``optimizer.new_variable_tags`` default. @@ -316,7 +321,7 @@ def propose(llm, rendered: str, task: Task, output: str, f"({len(train)}/{len(held_out)}/{len(test)}); nothing was fetched. A " "live run loads GSM8K and uses 64/64/64.",) if dry_run else () return MethodPolicy( - name="textgrad", + name=NAME, fidelity=FIDELITY, notes=( f"Traced against {UPSTREAM}: evaluation/prompt_optimization.py, textgrad/optimizer/optimizer.py (TextualGradientDescent), optimizer_prompts.py, autograd/llm_backward_prompts.py.", @@ -336,7 +341,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=gsm8k_reward, - proposal_calls_per_candidate=2, + proposal_calls_per_candidate=PROPOSAL_CALLS, reflective=True, ) diff --git a/examples/voyager/voyager_skill_library.py b/examples/voyager/voyager_skill_library.py index 666bc08f..7290a6be 100644 --- a/examples/voyager/voyager_skill_library.py +++ b/examples/voyager/voyager_skill_library.py @@ -44,6 +44,11 @@ FIDELITY = "environment_analogue" +#: The port's identity and reserved proposal calls, as metadata: a matrix +#: can list this port without calling :func:`build`, which loads its dataset. +NAME = "voyager" +PROPOSAL_CALLS = 1 + #: 48, not 12, and the size is a constraint rather than a garnish: `run_port` #: refuses a run whose train split is smaller than the worker count, so twelve #: goals split 4/4/4 capped this port at four workers with a four-goal gate. @@ -259,7 +264,7 @@ def propose(llm, rendered: str, task: Task, output: str, train, held_out, test = _split(seed) categories = ["skill generic"] + [f"skill {i}" for i in INGREDIENTS] return MethodPolicy( - name="voyager", + name=NAME, fidelity=FIDELITY, notes=( "A skill is added only when the environment judges the attempt successful, as add_new_skill is called only under info['success'].", @@ -283,7 +288,7 @@ def propose(llm, rendered: str, task: Task, output: str, solve=solve, propose=propose, reward=reward, - proposal_calls_per_candidate=1, + proposal_calls_per_candidate=PROPOSAL_CALLS, engine=Policies(task_sampler=DifficultyWeighted()), reflective=False, self_verify=True, From 1ca5fcb2975b2fbed4f5a0eb6bd427d992ead141 Mon Sep 17 00:00:00 2001 From: HugoXK Date: Wed, 25 Nov 2026 05:43:11 +0000 Subject: [PATCH 3/3] test(bench): drop both sample switches in the import-cost child tests/conftest.py sets AGENTDESCENT_GSM8K_SAMPLE and AGENTDESCENT_GSMHARD_SAMPLE, and run() popped only the first. The three GSM-HARD ports (godel_agent, reflexion, sica) therefore loaded their bundled sample, so an import-time build() of one of them passed the test that is supposed to catch it. Pop both. Measured after the change: an import-time reflexion_episodic_memory.build(0) fails 4 and passes 1, and promptbreeder_genetic_prompts.build(0) still fails 4 and passes 1 (the control). Before the change the reflexion mutation read 5 passed. Refs #1260. --- tests/test_bench_import_cost.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_bench_import_cost.py b/tests/test_bench_import_cost.py index 1462a043..a5054f47 100644 --- a/tests/test_bench_import_cost.py +++ b/tests/test_bench_import_cost.py @@ -70,13 +70,16 @@ def _read_only(*args, **kwargs): def run(body: str) -> subprocess.CompletedProcess: """Run ``body`` in a fresh interpreter that cannot write a dataset cache. - ``tests/conftest.py`` turns on the bundled GSM8K sample for the suite, and - that switch returns before the cache -- so it has to go, or every row here - would pass without the dataset path being reached at all. Without it the - child takes the path a reader's ``--help`` takes. + ``tests/conftest.py`` turns on the bundled sample for **both** domains and + each switch returns before the cache -- so both have to go, or the three + GSM-HARD ports (``reflexion``, ``self_refine``, ``sica``) would load their + bundled sample and an import-time build of one of them would pass here + without the dataset path being reached. Without them the child takes the + path a reader's ``--help`` takes. """ env = dict(os.environ) env.pop("AGENTDESCENT_GSM8K_SAMPLE", None) + env.pop("AGENTDESCENT_GSMHARD_SAMPLE", None) script = NO_CACHE + textwrap.dedent(body) return subprocess.run( [sys.executable, "-c", script],