Compare commits

..
Author SHA1 Message Date
fecoandClaude Opus 5.5 86758cf848 Merge main into prod: worker room and time for reasoning models
CI / test (push) Successful in 1m0s
CI / build (push) Successful in 20s
CI / deploy (push) Successful in 35s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-18 19:52:02 +00:00
fecoandClaude Opus 5.5 5af08ab689 Worker: room and time for reasoning models (32k tokens, 10 min), log answers that miss the schema
CI / test (push) Successful in 1m3s
CI / build (push) Successful in 4m6s
CI / deploy (push) Skipped
DeepSeek V4 Pro took 301 s for a natal analysis: the 300 s timeout cut it off
and the analysis was retried until it failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-18 19:48:36 +00:00
+9 -5
View File
@@ -8,8 +8,9 @@ use serde_json::{Value, json};
use super::prompt::{Prompt, validate}; use super::prompt::{Prompt, validate};
pub const DEFAULT_BASE_URL: &str = "https://openrouter.ai/api/v1"; pub const DEFAULT_BASE_URL: &str = "https://openrouter.ai/api/v1";
/// Room for reasoning tokens as well as the answer. /// Room for reasoning tokens as well as the answer: reasoning models (e.g.
const MAX_TOKENS: u32 = 16_000; /// DeepSeek) think at length before answering. Only a cap, not a cost.
const MAX_TOKENS: u32 = 32_000;
pub struct OpenRouter { pub struct OpenRouter {
http: reqwest::Client, http: reqwest::Client,
@@ -143,7 +144,8 @@ fn error_message(body: &Value, fallback: &str) -> String {
impl OpenRouter { impl OpenRouter {
pub fn new(base_url: &str, api_key: &str, referer: Option<String>) -> Self { pub fn new(base_url: &str, api_key: &str, referer: Option<String>) -> Self {
let http = reqwest::Client::builder() let http = reqwest::Client::builder()
.timeout(Duration::from_secs(300)) // Reasoning models can take several minutes for a long analysis.
.timeout(Duration::from_secs(600))
.connect_timeout(Duration::from_secs(10)) .connect_timeout(Duration::from_secs(10))
.build() .build()
.expect("HTTP client"); .expect("HTTP client");
@@ -203,8 +205,10 @@ impl OpenRouter {
let content = extract_json(raw).ok_or_else(|| { let content = extract_json(raw).ok_or_else(|| {
LlmError::Transient(format!("answer is not JSON: {}", raw.chars().take(200).collect::<String>())) LlmError::Transient(format!("answer is not JSON: {}", raw.chars().take(200).collect::<String>()))
})?; })?;
validate(&prompt.schema, &content) validate(&prompt.schema, &content).map_err(|e| {
.map_err(|e| LlmError::Transient(format!("answer does not match the schema: {e}")))?; tracing::warn!(model, answer = %raw.chars().take(500).collect::<String>(), "answer does not match the schema");
LlmError::Transient(format!("answer does not match the schema: {e}"))
})?;
let usage = &reply["usage"]; let usage = &reply["usage"];
let tokens = |key: &str| usage[key].as_i64().and_then(|n| i32::try_from(n).ok()); let tokens = |key: &str| usage[key].as_i64().and_then(|n| i32::try_from(n).ok());