Add Claude 4.x support and harden writeup pipeline#242
Open
SeoknamKo wants to merge 1 commit intoSakanaAI:mainfrom
Open
Add Claude 4.x support and harden writeup pipeline#242SeoknamKo wants to merge 1 commit intoSakanaAI:mainfrom
SeoknamKo wants to merge 1 commit intoSakanaAI:mainfrom
Conversation
- ai_scientist/llm.py: register claude-opus-4-7, claude-sonnet-4-6,
claude-haiku-4-5-20251001 in AVAILABLE_LLMS so they pass argparse
choices. Routing already works via the existing startswith("claude-")
dispatcher in create_client / get_response_from_llm.
- ai_scientist/perform_writeup.py: inject a LANGUAGE_RULE into the
abstract / section / Related Work prompts forcing English-only output,
and extend error_list to flag non-English text. This prevents
Aider's SEARCH/REPLACE blocks from failing to match when the LLM
writes non-English LaTeX comments (observed with Claude producing
Korean comments, breaking diff edits).
- launch_scientist.py:
* Guard `import torch` so sklearn-only templates (e.g. custom
materials / tabular experiments) keep working on environments
with a broken or missing torch install (common on Apple Silicon
conda base). get_available_gpus returns [] when torch is
unavailable.
* Add a `claude-*` branch to BOTH Coder.create() dispatchers
(experiments AND writeup). The writeup dispatcher was missing
the `anthropic/` model prefix, which caused Aider to mis-route
Claude models during the writeup phase.
* Bump `coder.max_reflections` to 6 (from Aider's default 3) after
each Coder.create so transient SEARCH/REPLACE mismatches don't
abort the run.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
claude-opus-4-7,claude-sonnet-4-6,claude-haiku-4-5-20251001) inAVAILABLE_LLMSso they are accepted by the CLI. Routing already works through the existingstartswith("claude-")dispatcher increate_client/get_response_from_llm.template.tex, Aider'sSEARCH/REPLACEblocks failed to match on subsequent edits, triggeringOnly 3 reflections allowed, stoppingand aborting the run. A newLANGUAGE_RULEis injected into the abstract / per-section / Related Work prompts, and a corresponding check is added toerror_list.Coder.create()dispatcher: it had noclaude-*branch, so Claude models were passed to Aider without the requiredanthropic/prefix. Experiments dispatcher had the branch; writeup did not. Both now match.coder.max_reflectionsfrom Aider's default 3 to 6 after eachCoder.create(), so transientSEARCH/REPLACEmismatches don't abort an otherwise healthy writeup.import torchwith a try/except.launch_scientist.pyonly uses torch for GPU enumeration (torch.cuda.device_count()), but a broken torch install (common on Apple Silicon conda setups with mixed pip/conda torch) caused immediateImportErrorat module load, even for sklearn-only templates.get_available_gpus()now returns[]when torch is missing or CUDA is unavailable.Why
This surfaced while running AI Scientist against a custom sklearn-only template with
claude-opus-4-7on an M4 Mac:claude-opus-4-7because it was not inAVAILABLE_LLMS.anthropic/prefix was only applied in the experiments dispatcher.torchinstall in the conda base env hard-blocked launch for templates that don't need torch at all.Each change is small and isolated, and keeps the existing behavior for non-Claude / torch-available setups intact.
Test plan
python launch_scientist.py --model claude-opus-4-7 --experiment <sklearn_template> --writeup latex --num-ideas 1completes through PDF generation on macOS M-series.python launch_scientist.py --model claude-sonnet-4-6 ...same.gpt-4o/claude-3-5-sonnet-20241022runs are unaffected (model dispatch unchanged for them).import launch_scientistsucceeds in an env wheretorchis broken;get_available_gpus()returns[].template.texfor any non-ASCII CJK ranges — should be empty.🤖 Generated with Claude Code