solvers/__init__.py: guard astabench imports so submodules can be used standalone#27
Merged
Merged
Conversation
…d standalone Wrap the astabench imports and astabench-dependent re-exports in try/except ImportError so submodules that don't need astabench (e.g. agent_baselines.solvers.inspect_swe) can be imported in environments where astabench isn't installed. No behavior change when astabench is installed.
9853fa0 to
0c650fa
Compare
rodneykinney
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agent_baselines/solvers/__init__.pyimportsastabench.util.modelat module top, so importing any submodule (e.g.agent_baselines.solvers.inspect_swe.agent) requiresastabenchto be installed in the venv.Some solvers under
solvers/are independent ofastabench(the inspect_swe wrapper,llm_with_prompt). Wrapping the astabench-touching imports intry/except ImportErrorlets those solvers be used from minimal environments that don't pull in astabench's transitive deps (e.g. an inspect_swe-only setup that needs newerlitellmthanastabench==0.5.xpins).No behavior change when astabench is installed.
Test plan
python -c "from agent_baselines.solvers.inspect_swe.agent import inspect_swe_solver"succeeds. (On main it raisesModuleNotFoundError: No module named 'astabench'while loadingsolvers/__init__.py.)futurehouse_solver,llm_with_prompt,normalize_model_name,record_model_usage_with_inspect) import the same as on main.