From 5573e0e8a2f9f3190c3afbf4632167f4173ba6bd Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 23 Feb 2026 12:30:25 -0500 Subject: [PATCH] Fix truncated LLM responses by populating catalog max_output Requests were always sent with max_tokens: None, which defaulted to 4096 in the Anthropic provider, causing large outputs to be truncated. Now build_request() looks up the model's max_output from the catalog and passes it through, giving each model its full output capacity. Co-Authored-By: Claude Opus 4.6 --- crates/agent/src/session.rs | 3 ++- crates/llm/src/catalog.json | 14 +++++++------- crates/llm/src/catalog.rs | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/agent/src/session.rs b/crates/agent/src/session.rs index f9bd504b0..dc7794f4f 100644 --- a/crates/agent/src/session.rs +++ b/crates/agent/src/session.rs @@ -396,7 +396,8 @@ impl Session { response_format: None, temperature: None, top_p: None, - max_tokens: None, + max_tokens: llm::catalog::get_model_info(self.provider_profile.model()) + .and_then(|m| m.max_output), stop_sequences: None, reasoning_effort: self.config.reasoning_effort.clone(), metadata: None, diff --git a/crates/llm/src/catalog.json b/crates/llm/src/catalog.json index 8f4c1e823..381f4a820 100644 --- a/crates/llm/src/catalog.json +++ b/crates/llm/src/catalog.json @@ -4,7 +4,7 @@ "provider": "anthropic", "display_name": "Claude Opus 4.6", "context_window": 200000, - "max_output": null, + "max_output": 128000, "supports_tools": true, "supports_vision": true, "supports_reasoning": true, @@ -17,7 +17,7 @@ "provider": "anthropic", "display_name": "Claude Sonnet 4.5", "context_window": 200000, - "max_output": null, + "max_output": 64000, "supports_tools": true, "supports_vision": true, "supports_reasoning": true, @@ -30,7 +30,7 @@ "provider": "openai", "display_name": "GPT-5.2", "context_window": 1047576, - "max_output": null, + "max_output": 128000, "supports_tools": true, "supports_vision": true, "supports_reasoning": true, @@ -43,7 +43,7 @@ "provider": "openai", "display_name": "GPT-5 Mini", "context_window": 1047576, - "max_output": null, + "max_output": 128000, "supports_tools": true, "supports_vision": true, "supports_reasoning": true, @@ -56,7 +56,7 @@ "provider": "openai", "display_name": "GPT-5.2 Codex", "context_window": 1047576, - "max_output": null, + "max_output": 128000, "supports_tools": true, "supports_vision": true, "supports_reasoning": true, @@ -69,7 +69,7 @@ "provider": "gemini", "display_name": "Gemini 3 Pro (Preview)", "context_window": 1048576, - "max_output": null, + "max_output": 65536, "supports_tools": true, "supports_vision": true, "supports_reasoning": true, @@ -82,7 +82,7 @@ "provider": "gemini", "display_name": "Gemini 3 Flash (Preview)", "context_window": 1048576, - "max_output": null, + "max_output": 65536, "supports_tools": true, "supports_vision": true, "supports_reasoning": true, diff --git a/crates/llm/src/catalog.rs b/crates/llm/src/catalog.rs index c01b896c7..6be91d4c2 100644 --- a/crates/llm/src/catalog.rs +++ b/crates/llm/src/catalog.rs @@ -52,6 +52,7 @@ mod tests { assert!(info.supports_vision); assert!(info.supports_reasoning); assert_eq!(info.context_window, 200_000); + assert_eq!(info.max_output, Some(128_000)); } #[test]