Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/forge_app/src/dto/anthropic/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ fn get_context_length(model_id: &str) -> Option<u64> {
return Some(1_000_000);
}

// Claude Sonnet 5 (1M context)
if model_id.starts_with("claude-sonnet-5") {
// Claude Sonnet 5 and Opus 5 (1M context)
if model_id.starts_with("claude-sonnet-5") || model_id.starts_with("claude-opus-5") {
return Some(1_000_000);
}

Expand Down
28 changes: 26 additions & 2 deletions crates/forge_app/src/transformers/model_specific_reasoning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ impl ModelSpecificReasoning {

fn family(&self) -> AnthropicModelFamily {
let id = self.model_id.to_lowercase();
if id.contains("opus-4-8")
if id.contains("opus-5")
|| id.contains("opus-4-8")
|| id.contains("48-opus")
|| id.contains("opus-4-7")
|| id.contains("47-opus")
|| id.contains("mythos")
|| id.contains("fable")
{
// Opus 4.8 shares Opus 4.7's API contract: adaptive thinking only
// Opus 5 and Opus 4.8 share Opus 4.7's API contract: adaptive thinking only
// (legacy `budget_tokens` returns 400) and non-default sampling
// params (`temperature`/`top_p`/`top_k`) return 400.
AnthropicModelFamily::AdaptiveOnly
Expand Down Expand Up @@ -188,6 +189,29 @@ mod tests {
assert_eq!(actual, expected);
}

#[test]
fn test_opus_5_drops_max_tokens_and_sampling_params() {
// Opus 5 shares the Opus 4.7/4.8 API contract: adaptive thinking only,
// legacy `budget_tokens` and non-default sampling params return 400.
let fixture = fixture_context_with_sampling().reasoning(ReasoningConfig {
enabled: Some(true),
max_tokens: Some(8000),
effort: Some(Effort::XHigh),
exclude: Some(true),
});

let actual = ModelSpecificReasoning::new("claude-opus-5").transform(fixture);

let expected = Context::default().reasoning(ReasoningConfig {
enabled: Some(true),
max_tokens: None,
effort: Some(Effort::XHigh),
exclude: Some(true),
});

assert_eq!(actual, expected);
}

#[test]
fn test_opus_4_8_strips_sampling_even_without_reasoning() {
let fixture = fixture_context_with_sampling();
Expand Down
7 changes: 5 additions & 2 deletions crates/forge_repo/src/provider/anthropic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ impl<H: HttpInfra> Anthropic<H> {
}

/// Returns false when the model auto-enables interleaved thinking through
/// adaptive thinking (Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5, Sonnet 4.6). When
/// adaptive thinking (Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5, Sonnet
/// 4.6). When
/// the model is unknown (e.g., listing endpoints), the flag is included because
/// it is harmless on non-chat endpoints and necessary on older chat models.
fn interleaved_thinking_required(model: Option<&ModelId>) -> bool {
let Some(model) = model else { return true };
let id = model.as_str().to_lowercase();
!(id.contains("opus-4-8")
!(id.contains("opus-5")
|| id.contains("opus-4-8")
|| id.contains("opus-4-7")
|| id.contains("opus-4-6")
|| id.contains("sonnet-4-6")
Expand Down Expand Up @@ -837,6 +839,7 @@ mod tests {
);

for model_id in [
"claude-opus-5",
"claude-opus-4-8",
"claude-opus-4-7",
"claude-opus-4-6",
Expand Down
10 changes: 10 additions & 0 deletions crates/forge_repo/src/provider/provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,16 @@
"supports_reasoning": true,
"input_modalities": ["text", "image"]
},
{
"id": "claude-opus-5",
"name": "Claude Opus 5",
"description": "Thoughtful and proactive model approaching frontier intelligence at half the price",
"context_length": 1000000,
"tools_supported": true,
"supports_parallel_tool_calls": true,
"supports_reasoning": true,
"input_modalities": ["text", "image"]
},
{
"id": "claude-opus-4-8",
"name": "Claude Opus 4.8",
Expand Down
Loading