fix: map Opus 4.6 to @default for Vertex AI#611
fix: map Opus 4.6 to @default for Vertex AI#611jeremyeder wants to merge 3 commits intoambient-code:mainfrom
Conversation
Opus 4.6 uses claude-opus-4-6@default on Vertex AI instead of the @yyyymmdd date suffix used by earlier models. Without this mapping, Vertex AI returns 404 for Opus 4.6 sessions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tests expected None/int inputs to raise TypeError, but dict.get() handles any hashable key without error — it returns the input unchanged. Updated tests to match actual behavior and removed unused pytest import. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This comment has been minimized.
This comment has been minimized.
Opus 4.1 is superseded by 4.5 and 4.6. Remove from frontend dropdown, Vertex AI model map, and all related tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Code ReviewSummaryThis PR adds Opus 4.6 support for Vertex AI by mapping Issues by Severity🚫 Blocker IssuesNone identified. 🔴 Critical IssuesNone identified. 🟡 Major Issues1. Formatting changes mixed with functional changes (auth.py) The Impact: Makes it difficult to identify the actual business logic change vs. formatting noise. Recommendation: In future PRs, separate auto-formatting commits from functional changes, or run formatters (black, isort) before starting work to avoid mixing concerns. 2. Missing validation for The function signature is def test_none_input_handling(self):
"""Test that None input passes through unchanged (dict.get handles it)"""
result = map_to_vertex_model(None) # type: ignore[arg-type]
assert result is None
def test_numeric_input_handling(self):
"""Test that numeric input passes through unchanged (dict.get handles it)"""
result = map_to_vertex_model(123) # type: ignore[arg-type]
assert result == 123Issues:
Recommendation:
Example of explicit validation: def map_to_vertex_model(model: str) -> str:
"""Map Anthropic API model names to Vertex AI model names."""
if not isinstance(model, str):
raise TypeError(f"model must be a string, got {type(model).__name__}")
return VERTEX_MODEL_MAP.get(model, model)This aligns with the error handling patterns in 🔵 Minor Issues1. Inconsistent test coverage for version suffix types The PR introduces two different version suffix patterns:
While # Version suffix is either "default" or YYYYMMDD date
assert version_suffix == "default" or (
len(version_suffix) == 8 and version_suffix.isdigit()
), f"Version suffix {version_suffix} should be 'default' or 8-digit date"Recommendation: Consider extracting version suffix validation into a helper function for clarity: def is_valid_vertex_version_suffix(suffix: str) -> bool:
"""Check if version suffix is either 'default' or YYYYMMDD date."""
return suffix == "default" or (len(suffix) == 8 and suffix.isdigit())
# Then in test:
assert is_valid_vertex_version_suffix(version_suffix), \
f"Invalid version suffix: {version_suffix}"2. Test naming could be more descriptive Test Recommendation: Consider renaming to
3. Frontend model ordering comment inconsistency In # Expected ordering: Sonnet → Opus 4.6 → Opus 4.5 → Haiku (matches frontend dropdown)But the assertions check: assert expected_order[0] == "claude-sonnet-4-5" # Balanced (default)
assert expected_order[1] == "claude-opus-4-6" # Latest Opus
assert expected_order[2] == "claude-opus-4-5" # Previous Opus
assert expected_order[3] == "claude-haiku-4-5" # FastestThis is correct, but the comment "Latest Opus" for 4.6 might be confusing since 4.6 is numerically higher than 4.5. Consider clarifying that this is the latest released Opus model. Positive Highlights✅ Comprehensive test coverage: 20 tests covering edge cases (case sensitivity, whitespace, partial matches, round-trip flows, ordering) ✅ Proper test organization: Separated unit tests ( ✅ Excellent PR description: Clear summary, context about why the mapping is needed, and explicit test plan ✅ Frontend consistency: Removed Opus 4.1 from both the dropdown and the backend mapping, maintaining consistency across the stack ✅ Version suffix documentation: Tests include inline comments explaining the difference between ✅ Fix for pre-existing test failures: Corrected invalid test expectations for RecommendationsPriority 1 (Address before merge)
Priority 2 (Nice to have)
Priority 3 (Future improvements)
Architecture Alignment✅ Follows project patterns: Changes align with established Python standards (black formatting, type hints) ✅ Test-driven: Comprehensive test suite validates all mappings and edge cases ✅ Configuration centralization: Model mappings are centralized in
Overall Assessment: This is a solid PR that correctly implements Opus 4.6 support for Vertex AI. The main concerns are around type safety and the mixing of formatting changes with functional changes. The test coverage is excellent and gives high confidence in the implementation. Recommendation: ✅ Approve with minor changes requested (address type validation in 🤖 Generated by Claude Code Review 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
Summary
claude-opus-4-6→claude-opus-4-6@defaultmapping toVERTEX_MODEL_MAP— without this, Vertex AI returns 404 for Opus 4.6 sessionstest_none_input_handlingandtest_numeric_input_handlingexpectedTypeErrorbutdict.get()handles any hashable key without errorpytestimportContext
PR #581 added Opus 4.6 support but mapped it to itself (no version suffix). We verified via live Vertex AI API calls that
claude-opus-4-6@defaultis the correct model identifier — the@YYYYMMDDdate convention doesn't apply to this model.Test plan
claude-opus-4-6@defaultreturns HTTP 200 from Vertex AI (us-east5, projectmy-project)🤖 Generated with Claude Code