Skip to content

fix(samplemath): make environment runnable end-to-end (closes #360) - #363

Merged
n0w0f merged 8 commits into
mainfrom
fix/samplemath-issue-360
Jun 11, 2026
Merged

fix(samplemath): make environment runnable end-to-end (closes #360)#363
n0w0f merged 8 commits into
mainfrom
fix/samplemath-issue-360

Conversation

@n0w0f

@n0w0f n0w0f commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #360. The samplemath environment failed to start after the documented setup. Six commits address each layer of the problem:

  • Replace the missing number_converter import in env.py and env_subtask.py with the already-defined percentage_calculator.
  • Drop the stale corral@git+https://github.com/lamalab-org/mat-agent-bench.git dependency from pyproject.toml and use the editable monorepo path (corral = { path = "../..", editable = true }) — same pattern as other environments.
  • CORRAL_WORK_DIR (with a tempdir fallback) in __main__, since Environment.__init__ now requires base_work_dir.
  • Update load_tasks_from_json to iterate the standardized list-of-entries schema used by the bundled environments/level_1/{tasks,subtasks}_json/task_1.json files (each entry carries its own id).
  • Add [tool.setuptools.packages.find] include = ["samplemath*"] so uv sync no longer trips on the flat layout (samplemath/ + environments/).

Test plan

  • uv sync resolves without falling back to the renamed remote.
  • MathEnvironment(...) constructs and registers calculator, percentage_calculator, unit_converter.
  • create_environments('environments/level_1/subtasks_json/task_1.json') builds task1..task4 with their declared tools.
  • grep -r "number_converter\|mat-agent-bench" tasks/samplemath is empty.
  • Standalone server smoke test (python samplemath/env.py, port 8011): GET /tasks, /tasks/math_1/prompt, /tasks/math_1/tools, POST /tools/execute (calculator add 23+45 → 68), POST /submit answer "68" → score 1.0.
  • Subtask server smoke test (python samplemath/env_subtask.py environments/level_1/subtasks_json/task_1.json, port 8012): GET /tasks returns task1..task4, /tasks/task1/prompt shows "First Addition / 3 + 5", POST /tools/execute (calculator add 3+5 → 8), POST /submit answer "8" → score 1.0.

Summary by Sourcery

Make the samplemath environment runnable end-to-end by aligning tooling, task loading, and project configuration with the current corral setup.

Bug Fixes:

  • Fix MathEnvironment tool registration by replacing the obsolete number_converter with percentage_calculator.
  • Ensure MathEnvironment and subtask environments initialize correctly by passing a base work directory, with a sensible default derived from CORRAL_WORK_DIR or a temporary directory.
  • Update subtask JSON task loading to handle the standardized list-of-entries schema with per-entry IDs and settings.

Enhancements:

  • Wire percentage_calculator into subtask-specific tools to match the main environment tooling.

Build:

  • Switch the samplemath corral dependency from a remote git URL to the local editable monorepo source via uv configuration.
  • Configure setuptools package discovery for the flat samplemath layout so the environment is packaged and importable correctly.

Summary by CodeRabbit

  • Configuration

    • Switched dependency configuration to use local editable paths
    • Enhanced package discovery for the sample math module
  • Refactor

    • Environment now respects a configurable work directory for task runs
    • Updated task loader to support a new JSON structure for tasks
    • Adjusted per-task tool configuration used during execution

n0w0f added 5 commits June 1, 2026 10:50
…culator in env.py

number_converter is not defined in tools.py; use the existing
percentage_calculator instead so MathEnvironment can be instantiated.

Refs #360
…culator in env_subtask.py

Mirror the env.py fix: number_converter does not exist in tools.py.
Map percentage_calculator into the subtask tool registry instead.

Refs #360
The old git+https://github.com/lamalab-org/mat-agent-bench.git URL
references the pre-rename repository, so 'uv sync' resolves a different
codebase than the surrounding source. Switch to the editable path
dependency on '../..' that the other task envs (catalyst, ml) already use.

Refs #360
…t API

Environment.__init__ now requires base_work_dir; the standalone
MathEnvironment was still constructed without one and crashed on
startup. Thread base_work_dir through MathEnvironment and read
CORRAL_WORK_DIR (with a tempdir fallback) in __main__, matching the
subtask environment's contract.

Also tighten setuptools package discovery so 'uv sync' does not bail
on the flat layout containing both 'samplemath' and 'environments',
and refresh uv.lock to drop the stale mat-agent-bench source.

Refs #360
The bundled environments/level_1/{tasks_json,subtasks_json}/task_1.json
files use the standardized list-of-entries schema (each entry carrying
its own 'id'), but load_tasks_from_json still iterated as a dict and
crashed with AttributeError. Accept both shapes so the documented
'python samplemath/env_subtask.py environments/...' invocation works.

Refs #360
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@n0w0f, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 1 minute and 2 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b02270b-66ba-424b-9082-1e27172a0e5f

📥 Commits

Reviewing files that changed from the base of the PR and between 6f260e2 and cf73120.

📒 Files selected for processing (2)
  • tasks/samplemath/samplemath/env.py
  • tasks/samplemath/samplemath/env_subtask.py
📝 Walkthrough

Walkthrough

Switch corral to a local editable path and add setuptools package discovery; thread an optional base_work_dir through MathEnvironment and main; replace missing number_converter with percentage_calculator across env files; and update task JSON loading to iterate per-task entries and build TaskDefinition objects.

Changes

Environment setup and tool registration fix

Layer / File(s) Summary
Packaging and dependency configuration
tasks/samplemath/pyproject.toml
Switch corral from a remote git reference to a local editable path (path = "../..", editable = true) and add [tool.setuptools.packages.find] to include samplemath* packages.
MathEnvironment initialization and tool setup
tasks/samplemath/samplemath/env.py
Add optional base_work_dir parameter forwarded to Environment, replace number_converter with percentage_calculator in tool setup, and read/pass CORRAL_WORK_DIR into created MathEnvironment instances in __main__.
Subtask environment and JSON task parsing
tasks/samplemath/samplemath/env_subtask.py
Replace import/use of number_converter with percentage_calculator, register it in subtask-specific tool mappings, and refactor load_tasks_from_json to iterate array entries and construct TaskDefinition from per-task fields (keeping work_dir injection into initial_input).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through code and dirt,
Swaps a missing tool and tidies the work,
Paths now local, tasks read aright,
Samplemath hums through day and night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(samplemath): make environment runnable end-to-end (closes #360)' accurately describes the main objective of the PR—fixing the samplemath environment to work end-to-end by resolving import errors and configuration issues.
Linked Issues check ✅ Passed The PR successfully addresses all coding-related objectives from issue #360: removes the nonexistent number_converter import and replaces it with percentage_calculator [#360], updates dependency configuration to use local editable path [#360], fixes work-dir handling in Environment initialization [#360], and updates JSON task loading to match the standardized schema [#360].
Out of Scope Changes check ✅ Passed All changes are scoped to resolving the end-to-end execution failures: dependency fixes in pyproject.toml, import/tool registration corrections in env.py and env_subtask.py, work-dir parameter passing, and task JSON schema alignment. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/samplemath-issue-360

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Makes the samplemath environment runnable end-to-end by wiring it to the current corral APIs, fixing tool registrations, aligning JSON task loading with the standardized schema, and updating packaging/dependency configuration for monorepo usage.

Flow diagram for load_tasks_from_json with standardized entry list

flowchart LR
    A["load_tasks_from_json(task_json_path, work_dir)"] --> B["json.load"]
    B --> C["for entry in task_data"]
    C --> D["task_id = entry['id']"]
    D --> E["scoring_fn_name = entry.get('scoring_function', 'default')"]
    E --> F["get_scoring_function(scoring_fn_name, scoring_params)"]
    F --> G["initial_input = entry.get('initial_input', {}).copy()"]
    G --> H{"work_dir in initial_input?"}
    H -- no --> I["initial_input['work_dir'] = work_dir"]
    H -- yes --> J["keep existing work_dir"]
    I --> K["TaskDefinition(..., tools=entry.get('tools', []), initial_input=initial_input)"]
    J --> K
    K --> L["tasks[task_id] = TaskDefinition"]
    L --> M["return tasks"]
Loading

File-Level Changes

Change Details Files
Update MathEnvironment to support required base_work_dir parameter and correct tool wiring, and ensure the standalone server uses a valid working directory.
  • Add optional base_work_dir argument to MathEnvironment.init and pass it through to Environment.init
  • Replace the obsolete number_converter tool with percentage_calculator when registering tools
  • Compute base_work_dir from CORRAL_WORK_DIR or a temp directory in the main block and pass it to all MathEnvironment instances
tasks/samplemath/samplemath/env.py
Align subtask environment with the standardized tasks JSON schema and current tool naming.
  • Change load_tasks_from_json to iterate a list of task entries, extracting id and other fields from each entry instead of assuming a dict keyed by task_id
  • Ensure initial_input always includes work_dir while copying from each entry
  • Swap number_converter for percentage_calculator in subtask-specific tool mapping passed into create_environments
tasks/samplemath/samplemath/env_subtask.py
Adjust project dependencies and packaging configuration for samplemath to work within the monorepo and with uv.
  • Replace the git-based corral dependency with a regular corral requirement and add a [tool.uv.sources] path-based editable dependency pointing at the monorepo root
  • Configure setuptools to find samplemath packages via [tool.setuptools.packages.find] include = ["samplemath*"] so uv sync works with the flat layout
tasks/samplemath/pyproject.toml
tasks/samplemath/uv.lock

Assessment against linked issues

Issue Objective Addressed Explanation
#360 Resolve the ImportError in the samplemath environment by fixing the missing number_converter reference so that the environment starts successfully after the documented setup.
#360 Fix the import/path setup for corral so that the samplemath environment can reliably import corral.backend... after following the documented repository setup (without confusion between corral.backend and src.corral.backend).

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

The bundled task JSON files (and the shared loader in
src/corral/utils/task_loader.py) all use the list-of-entries schema,
so the dict fallback was speculative dead code. Iterate the list
directly.

Refs #360
@n0w0f
n0w0f marked this pull request as ready for review June 4, 2026 04:31
@n0w0f
n0w0f requested review from MrtinoRG and kjappelbaum June 4, 2026 04:32

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In MathEnvironment.__init__, consider making base_work_dir a required argument or defaulting to None and validating it rather than using an empty string, so that any new call sites that forget to pass it fail fast instead of silently inheriting a potentially invalid work directory.
  • In load_tasks_from_json, you now assume a list of entries with required keys like id, name, and description; adding a quick schema/shape check with a clear error message would make failures on malformed task JSONs easier to debug than the current KeyError/TypeError behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `MathEnvironment.__init__`, consider making `base_work_dir` a required argument or defaulting to `None` and validating it rather than using an empty string, so that any new call sites that forget to pass it fail fast instead of silently inheriting a potentially invalid work directory.
- In `load_tasks_from_json`, you now assume a list of entries with required keys like `id`, `name`, and `description`; adding a quick schema/shape check with a clear error message would make failures on malformed task JSONs easier to debug than the current `KeyError`/`TypeError` behavior.

## Individual Comments

### Comment 1
<location path="tasks/samplemath/samplemath/env.py" line_range="36-37" />
<code_context>


 if __name__ == "__main__":
+    base_work_dir = os.environ.get(
+        "CORRAL_WORK_DIR", tempfile.mkdtemp(prefix="samplemath_")
+    )
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Using `tempfile.mkdtemp` here can leave behind uncleaned temporary directories.

The fallback creates a persistent directory that is never removed, so repeated runs can accumulate many `samplemath_*` dirs. Either use a deterministic path under a known temp root, or add cleanup at process exit (e.g., via `atexit` or by delegating lifecycle management to `Environment`).

Suggested implementation:

```python
if __name__ == "__main__":
    base_work_dir = os.environ.get(
        "CORRAL_WORK_DIR",
        os.path.join(tempfile.gettempdir(), "samplemath_workdir"),
    )

```

Ensure the module imports `os` and `tempfile` at the top of the file:

1. Add (or confirm) `import os`.
2. Add (or confirm) `import tempfile`.

No further lifecycle management is required with this change because the fallback is now a single deterministic directory, avoiding accumulation of many `samplemath_*` directories across runs.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tasks/samplemath/samplemath/env.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tasks/samplemath/samplemath/env_subtask.py`:
- Around line 160-164: The fallback value "default" for scoring_function is
invalid and causes get_scoring_function to fail; update the task loading loop to
use a real default such as "addition_score" (or "multiplication_score") instead
of "default", or validate and raise a clear schema error when scoring_function
is missing; change the line that sets scoring_fn_name in the for-loop (task_data
/ scoring_function) to a valid key from SCORING_FUNCTIONS (addition_score or
multiplication_score) or add an explicit check that raises a descriptive error
before calling get_scoring_function.
- Line 8: Change package-relative imports in env_subtask.py (and corresponding
import in env.py) from "from tools import calculator, percentage_calculator" to
a package-qualified import such as "from samplemath.tools import calculator,
percentage_calculator" so the module works when installed as the samplemath
package. In load_tasks_from_json, stop defaulting scoring_function to "default"
(which isn't in SCORING_FUNCTIONS) — either change the default to a valid key
like "addition_score" or update the code to map unknown/missing scoring_function
values to a safe fallback (e.g., scoring = scoring_function if scoring_function
in SCORING_FUNCTIONS else "addition_score" or use
SCORING_FUNCTIONS.get(scoring_function, SCORING_FUNCTIONS["addition_score"])) to
avoid raising ValueError; reference the SCORING_FUNCTIONS dict and the
load_tasks_from_json function when making this change.

In `@tasks/samplemath/samplemath/env.py`:
- Around line 36-38: The current assignment to base_work_dir calls
tempfile.mkdtemp(...) regardless of CORRAL_WORK_DIR which creates a leftover
temp dir; change it to first read env_var = os.environ.get("CORRAL_WORK_DIR")
and only call tempfile.mkdtemp(prefix="samplemath_") when env_var is falsy, then
assign base_work_dir = env_var or the newly created temp dir (update this logic
inside env.py where base_work_dir is defined).
- Line 4: Replace the top-level import and eager temp-dir creation in env.py:
change the import from "from tools import UnitConverterTool, calculator,
percentage_calculator" to a package-relative import (e.g., "from .tools import
UnitConverterTool, calculator, percentage_calculator") so the module works when
installed as a package, and avoid calling tempfile.mkdtemp() unconditionally for
the CORRAL_WORK_DIR fallback — only call tempfile.mkdtemp() when
os.environ.get("CORRAL_WORK_DIR") is None (e.g., check the env var first and
create the temp dir only in that branch) so the temp directory is not allocated
when CORRAL_WORK_DIR is already set.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fbc8fe6a-0550-48dc-9ea7-fd716ecb692d

📥 Commits

Reviewing files that changed from the base of the PR and between 9b09bbc and f34bfd4.

⛔ Files ignored due to path filters (1)
  • tasks/samplemath/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • tasks/samplemath/pyproject.toml
  • tasks/samplemath/samplemath/env.py
  • tasks/samplemath/samplemath/env_subtask.py

Comment thread tasks/samplemath/samplemath/env_subtask.py Outdated
Comment thread tasks/samplemath/samplemath/env_subtask.py
Comment thread tasks/samplemath/samplemath/env.py Outdated
The mkdtemp fallback leaked a new samplemath_* temp dir on every run.
Match the convention used by sibling tasks (corral_md, spectra_elucidation)
with a deterministic relative path and drop the unused tempfile import.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tasks/samplemath/samplemath/env.py (1)

3-3: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Use package-relative import for tools.

The import statement from tools import ... was flagged in a previous review and remains unaddressed. When samplemath is installed as a package, this absolute import will fail because tools won't be directly on sys.path.

📦 Proposed fix
-from tools import UnitConverterTool, calculator, percentage_calculator
+from .tools import UnitConverterTool, calculator, percentage_calculator
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tasks/samplemath/samplemath/env.py` at line 3, The import in env.py uses a
top-level module name "tools" which breaks when samplemath is installed; change
it to a package-relative import so Python resolves the module inside the
samplemath package (e.g. import the three symbols from the local tools module
using a relative import), ensuring UnitConverterTool, calculator and
percentage_calculator are imported from the package-local tools module.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tasks/samplemath/samplemath/env.py`:
- Around line 35-37: The fallback base_work_dir uses a fragile relative path;
update the assignment of base_work_dir in env.py (the base_work_dir variable) to
use a module-relative path (e.g., based on __file__ /
Path(__file__).resolve().parent) instead of "../CORRAL_WORK_DIR/samplemath", and
after determining the path call mkdir(parents=True, exist_ok=True) to ensure the
directory exists before Environment or trial workspace creation; mirror the
approach used in env_subtask.py for determining and creating the directory.

---

Duplicate comments:
In `@tasks/samplemath/samplemath/env.py`:
- Line 3: The import in env.py uses a top-level module name "tools" which breaks
when samplemath is installed; change it to a package-relative import so Python
resolves the module inside the samplemath package (e.g. import the three symbols
from the local tools module using a relative import), ensuring
UnitConverterTool, calculator and percentage_calculator are imported from the
package-local tools module.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 516a7d25-ee64-4a4b-97dc-09be7a4c0e91

📥 Commits

Reviewing files that changed from the base of the PR and between f34bfd4 and 6f260e2.

📒 Files selected for processing (1)
  • tasks/samplemath/samplemath/env.py

Comment on lines +35 to +37
base_work_dir = os.environ.get(
"CORRAL_WORK_DIR", "../CORRAL_WORK_DIR/samplemath"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Hardcoded relative path is fragile and may not exist.

The fallback "../CORRAL_WORK_DIR/samplemath" is relative to the current working directory at runtime, making it unpredictable. Additionally, there's no mkdir() call to ensure the directory exists before Environment tries to create trial workspaces under it (see context snippet 2).

Following the pattern in env_subtask.py, use a module-relative path and ensure it exists.

🛠️ Proposed fix
+from pathlib import Path
+
 import os

-from tools import UnitConverterTool, calculator, percentage_calculator
+from .tools import UnitConverterTool, calculator, percentage_calculator
 if __name__ == "__main__":
-    base_work_dir = os.environ.get(
-        "CORRAL_WORK_DIR", "../CORRAL_WORK_DIR/samplemath"
-    )
+    base_work_dir = os.environ.get("CORRAL_WORK_DIR")
+    if not base_work_dir:
+        base_work_dir = str(Path(__file__).parent / "work_dir")
+    Path(base_work_dir).mkdir(parents=True, exist_ok=True)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tasks/samplemath/samplemath/env.py` around lines 35 - 37, The fallback
base_work_dir uses a fragile relative path; update the assignment of
base_work_dir in env.py (the base_work_dir variable) to use a module-relative
path (e.g., based on __file__ / Path(__file__).resolve().parent) instead of
"../CORRAL_WORK_DIR/samplemath", and after determining the path call
mkdir(parents=True, exist_ok=True) to ensure the directory exists before
Environment or trial workspace creation; mirror the approach used in
env_subtask.py for determining and creating the directory.

- Import tools via samplemath.tools so the package works when installed,
  not only when run as a script with its dir on sys.path (matches catalyst).
- Make scoring_function required in load_tasks_from_json; the old 'default'
  fallback pointed at a key absent from SCORING_FUNCTIONS, raising a cryptic
  error. Now fails with the offending task id and the valid options.
@n0w0f
n0w0f merged commit 88d9b67 into main Jun 11, 2026
18 checks passed
@n0w0f
n0w0f deleted the fix/samplemath-issue-360 branch June 11, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SampleMath environment fails to run after documented setup

2 participants