Skip to content

Defaulting to using claude-sonnet-4-6 for specification generation and repair#173

Open
jyoo980 wants to merge 6 commits intomainfrom
yoo/default-claude
Open

Defaulting to using claude-sonnet-4-6 for specification generation and repair#173
jyoo980 wants to merge 6 commits intomainfrom
yoo/default-claude

Conversation

@jyoo980
Copy link
Copy Markdown
Collaborator

@jyoo980 jyoo980 commented Apr 23, 2026

This should have ideally been a single-line change (swapping out the model), but the Anthropic API (which is called by LiteLLM) does not support a top_k parameter.

The workaround is to issue top_k parallel requests, which is implemented by this PR.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@jyoo980 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 51 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 51 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 068c4458-fc95-4c94-a444-7ea31cc866bb

📥 Commits

Reviewing files that changed from the base of the PR and between 36c15f6 and 523c4ce.

📒 Files selected for processing (2)
  • main.py
  • models/default_llm_backend.py
📝 Walkthrough

Walkthrough

The pull request migrates the default LLM model from OpenAI's gpt-4o to Anthropic's claude-sonnet-4-6. It updates documentation to instruct users to provide an ANTHROPIC_API_KEY environment variable for specification generation and repair. The LLM backend implementation is modified to read ANTHROPIC_API_KEY for Claude models and LLM_API_KEY for others, and to use parallel single-request generation for Claude models instead of leveraging the n parameter.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 yoo/default-claude

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.

@jyoo980 jyoo980 requested a review from mernst April 23, 2026 22:47
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
main.py (1)

193-200: ⚠️ Potential issue | 🟡 Minor

Update --stub-out-llm help text — it still references only LLM_API_KEY.

With the new default model claude-sonnet-4-6, DefaultLlmBackend.__init__ reads ANTHROPIC_API_KEY (not LLM_API_KEY) for the default flow. The help text is now stale and will mislead users debugging CI runs.

📝 Suggested diff
     parser.add_argument(
         "--stub-out-llm",
         action="store_true",
         help=(
             "Stub out the LLM client (e.g., for integration tests). Otherwise, the constructor "
-            "looks for an environment variable (LLM_API_KEY) that is not available on a CI runner."
+            "looks for a model-specific API key (ANTHROPIC_API_KEY for Claude models, "
+            "LLM_API_KEY otherwise) that is not available on a CI runner."
         ),
     )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@main.py` around lines 193 - 200, The --stub-out-llm argument help text is
stale (mentions only LLM_API_KEY) while DefaultLlmBackend.__init__ now reads
ANTHROPIC_API_KEY for the default model; update the parser.add_argument help
string for "--stub-out-llm" to reference ANTHROPIC_API_KEY (and optionally
LLM_API_KEY for backward compatibility) or generalize to "the required LLM API
key environment variable (e.g., ANTHROPIC_API_KEY)" so users running CI see the
correct env var to set when the LLM client is not stubbed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@models/default_llm_backend.py`:
- Line 179: The error message raised by ModelError in the Claude/Anthropic retry
branch of _send_one_message is misleadingly hard-coded to "Vertex AI API: Too
many retries"; update the raise call in that branch (and the similar one at the
non‑Claude path) to use a generic message that reflects the actual LLM client,
e.g. "LLM API: Too many retries" or include the model identifier via self.model,
so logs/alerts correctly indicate which backend exhausted retries.
- Around line 112-185: The retry + context-compaction loop in _send_one_message
is duplicated with send_messages; extract that shared logic into a private
helper (suggest name _completion_with_retry) that accepts parameters used in the
loop (messages, temperature, n/top_k as optional, model, api_key,
vertex_credentials, max_tokens) and implements the retry count/backoff, context
compaction, and exception mapping, returning the raw completion response; then
update send_messages to call _completion_with_retry(n=top_k) and unpack the n
choices, and simplify _send_one_message to call _completion_with_retry(n=1) and
return the single choice, leaving _send_parallel unchanged except it will call
the simplified _send_one_message. Ensure the new helper references the existing
completion call and preserves all exception types and retry behavior.
- Around line 37-40: Introduce a single helper method _is_claude(model_name)
that centralizes all Claude-detection logic and replace every predicate
occurrence (model.startswith("claude"), "claude" in model, and "claude" in
self.model) with calls to _is_claude(...) in send_messages, _send_parallel,
_send_one_message and any other places; change the misleading error string in
_send_one_message from "Vertex AI API: Too many retries" to the
provider-agnostic "LLM API: Too many retries"; and factor the duplicated
retry/compaction logic shared by send_messages (non-parallel path) and
_send_one_message (parallel path) into a single helper (e.g.,
_retry_and_compact) that both paths call to avoid duplication.

In `@README.md`:
- Around line 14-22: The README implies both LLM_API_KEY and ANTHROPIC_API_KEY
are mandatory; update it to state that because DEFAULT_MODEL =
"claude-sonnet-4-6" in main.py, the default flow only requires ANTHROPIC_API_KEY
and show a single echo example for ANTHROPIC_API_KEY, then note that LLM_API_KEY
is only needed when using a non-Claude model (e.g., when passing --model gpt-4o)
and show an additional echo command for LLM_API_KEY as a conditional step;
mention DEFAULT_MODEL and the --model flag to make the mapping explicit.

---

Outside diff comments:
In `@main.py`:
- Around line 193-200: The --stub-out-llm argument help text is stale (mentions
only LLM_API_KEY) while DefaultLlmBackend.__init__ now reads ANTHROPIC_API_KEY
for the default model; update the parser.add_argument help string for
"--stub-out-llm" to reference ANTHROPIC_API_KEY (and optionally LLM_API_KEY for
backward compatibility) or generalize to "the required LLM API key environment
variable (e.g., ANTHROPIC_API_KEY)" so users running CI see the correct env var
to set when the LLM client is not stubbed.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 47afb43c-b995-41f8-8490-12b424433d5c

📥 Commits

Reviewing files that changed from the base of the PR and between b02c9c7 and 36c15f6.

📒 Files selected for processing (3)
  • README.md
  • main.py
  • models/default_llm_backend.py

Comment thread models/default_llm_backend.py Outdated
Comment thread models/default_llm_backend.py Outdated
Comment thread models/default_llm_backend.py Outdated
Comment thread README.md
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.

2 participants