From e7e54acaeede9145392133a7da36487212cbce0e Mon Sep 17 00:00:00 2001 From: Sasha Malahov Date: Thu, 6 Aug 2026 01:20:14 -0400 Subject: [PATCH 1/3] fix: workaround Python match scoping issue in generation_loop --- compass/generators/_loop.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compass/generators/_loop.py b/compass/generators/_loop.py index 0f0a45a..8d9c382 100644 --- a/compass/generators/_loop.py +++ b/compass/generators/_loop.py @@ -86,13 +86,13 @@ def generation_loop( case Ok(raw): pass - match parse(raw): - case Err(e): - msg = f"[Round {round_num}] Type error: {e}" - ctx = ctx.with_feedback(msg) - continue - case Ok(spec): - pass + parsed_result = parse(raw) + if isinstance(parsed_result, Ok): + spec = parsed_result.value + else: + msg = f"[Round {round_num}] Type error: {parsed_result.error}" + ctx = ctx.with_feedback(msg) + continue logger.info("Spec parsed successfully") From c59b77f0bcac200d69af707d61f71da8904072ae Mon Sep 17 00:00:00 2001 From: Sasha Malahov Date: Fri, 7 Aug 2026 13:19:42 -0400 Subject: [PATCH 2/3] refactor: update letsplot_notebook to use four.generators framework - Rebase imports from compass.generators.* to four.generators.* - Uses the shared generators framework from four repository --- compass/generators/letsplot_notebook/_context.py | 2 +- compass/generators/letsplot_notebook/_runtime.py | 6 +++--- compass/generators/letsplot_notebook/_types.py | 2 +- compass/generators/letsplot_notebook/generate.py | 16 ++++++++-------- trajectory.json | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/compass/generators/letsplot_notebook/_context.py b/compass/generators/letsplot_notebook/_context.py index c6285ae..f5115c8 100644 --- a/compass/generators/letsplot_notebook/_context.py +++ b/compass/generators/letsplot_notebook/_context.py @@ -6,7 +6,7 @@ from __future__ import annotations -from compass.generators._types import DomainSection, GenerationContext +from four.generators._types import DomainSection, GenerationContext # Key geoms and their use cases _LETSPLOT_GEOMS = """\ diff --git a/compass/generators/letsplot_notebook/_runtime.py b/compass/generators/letsplot_notebook/_runtime.py index 977342b..e7bcd9c 100644 --- a/compass/generators/letsplot_notebook/_runtime.py +++ b/compass/generators/letsplot_notebook/_runtime.py @@ -13,19 +13,19 @@ from pathlib import Path from typing import Any -from compass.generators._types import ( +from four.generators._types import ( AskFn, Err, GenerationContext, Ok, Result, ) -from compass.generators._invoke import ( +from four.generators._invoke import ( build_system_prompt, build_user_message, resolve_ask_fn, ) -from compass.generators._validation import ( +from four.generators._validation import ( validate_python_sources, ) diff --git a/compass/generators/letsplot_notebook/_types.py b/compass/generators/letsplot_notebook/_types.py index 1ec5117..4a8fa9d 100644 --- a/compass/generators/letsplot_notebook/_types.py +++ b/compass/generators/letsplot_notebook/_types.py @@ -11,7 +11,7 @@ from dataclasses import dataclass from typing import Optional -from compass.generators._types import Err, Ok, Result +from four.generators._types import Err, Ok, Result @dataclass(frozen=True) diff --git a/compass/generators/letsplot_notebook/generate.py b/compass/generators/letsplot_notebook/generate.py index 9ef4cab..2bdac3d 100644 --- a/compass/generators/letsplot_notebook/generate.py +++ b/compass/generators/letsplot_notebook/generate.py @@ -6,18 +6,18 @@ G'_letsplot : (LetsPlotNotebookSpec, Error) -> NotebookPatch -> LetsPlotNotebookSpec Usage: - python -m compass.generators.letsplot_notebook.generate \\ + python -m four.generators.letsplot_notebook.generate \\ --prompt "Create a notebook comparing geom_hex and geom_pointdensity" \\ --output-dir ./notebooks - python -m compass.generators.letsplot_notebook.generate \\ + python -m four.generators.letsplot_notebook.generate \\ --prompt "Show marginal plots with ggmarginal" --dry-run # Interactive REPL - python -m compass.generators.letsplot_notebook.generate --live + python -m four.generators.letsplot_notebook.generate --live # Refine existing notebook - python -m compass.generators.letsplot_notebook.generate \\ + python -m four.generators.letsplot_notebook.generate \\ --refine notebooks/scatter_analysis.ipynb \\ --claim "Add a geom_density2d comparison" """ @@ -30,14 +30,14 @@ import sys from pathlib import Path -from compass.generators._types import ( +from four.generators._types import ( Err, GenerationContext, GenerationReport, Ok, Result, ) -from compass.generators._loop import generation_loop, refine_context, result_to_exit +from four.generators._loop import generation_loop, refine_context, result_to_exit from ._types import LetsPlotNotebookSpec, validate_spec_instance from ._runtime import ( @@ -155,7 +155,7 @@ def run( ctx = ctx.with_prompt(prompt) if dry_run: - from compass.generators._invoke import build_system_prompt, build_user_message + from four.generators._invoke import build_system_prompt, build_user_message system = build_system_prompt( ctx, (Path(__file__).parent / "_types.py").read_text(), @@ -257,7 +257,7 @@ def main() -> int: logging.basicConfig(level=logging.INFO) if args.live: - from compass.generators._loop import repl_loop + from four.generators._loop import repl_loop ctx = build_letsplot_context() return result_to_exit(repl_loop( diff --git a/trajectory.json b/trajectory.json index b87734d..07cac0b 100644 --- a/trajectory.json +++ b/trajectory.json @@ -3,7 +3,7 @@ "messages": [ { "role": "system", - "content": "" + "content": "You are a bash agent. You solve tasks by executing bash commands. Wrap each command in a ```bash ... ``` block. When the task is fully done, respond with plain text instead of a code block." }, { "role": "user", @@ -11,16 +11,16 @@ }, { "role": "assistant", - "content": "[{\"tool_call_id\": \"C92k8aQ4IzW2JjuFJutXVDJIjxNRxf6K\", \"name\": \"bash\", \"arguments\": \"{\\\"command\\\":\\\"find /tmp -maxdepth 1 -name \\\\\\\"*.py\\\\\\\" -type f\\\"}\"}]" + "content": "[{\"tool_call_id\": \"call_mGmISvlNX7tcqJihCTVhlO7mgDroKfLN\", \"name\": \"bash\", \"arguments\": \"{\\\"command\\\":\\\"find /tmp -maxdepth 1 -name \\\\\\\"*.py\\\\\\\" -type f\\\"}\"}]" }, { "role": "tool", "content": "0\n\n\n", - "tool_call_id": "C92k8aQ4IzW2JjuFJutXVDJIjxNRxf6K" + "tool_call_id": "call_mGmISvlNX7tcqJihCTVhlO7mgDroKfLN" }, { "role": "assistant", - "content": "There are no `.py` files currently located in the `/tmp` directory." + "content": "There are no `.py` files in the `/tmp` directory." } ] } \ No newline at end of file From d40070e7266cbef8eda152e831ff59f36bebe599 Mon Sep 17 00:00:00 2001 From: Sasha Malahov Date: Fri, 7 Aug 2026 13:30:08 -0400 Subject: [PATCH 3/3] refactor: update letsplot_notebook to use four.generators framework --- trajectory.json | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 trajectory.json diff --git a/trajectory.json b/trajectory.json deleted file mode 100644 index 07cac0b..0000000 --- a/trajectory.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "outcome": "exit:task_complete", - "messages": [ - { - "role": "system", - "content": "You are a bash agent. You solve tasks by executing bash commands. Wrap each command in a ```bash ... ``` block. When the task is fully done, respond with plain text instead of a code block." - }, - { - "role": "user", - "content": "List .py files in /tmp" - }, - { - "role": "assistant", - "content": "[{\"tool_call_id\": \"call_mGmISvlNX7tcqJihCTVhlO7mgDroKfLN\", \"name\": \"bash\", \"arguments\": \"{\\\"command\\\":\\\"find /tmp -maxdepth 1 -name \\\\\\\"*.py\\\\\\\" -type f\\\"}\"}]" - }, - { - "role": "tool", - "content": "0\n\n\n", - "tool_call_id": "call_mGmISvlNX7tcqJihCTVhlO7mgDroKfLN" - }, - { - "role": "assistant", - "content": "There are no `.py` files in the `/tmp` directory." - } - ] -} \ No newline at end of file