From 0a830347dcf914d71484e0906dd395610e09d4df Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 1 Sep 2026 11:08:39 +0200 Subject: [PATCH] Bound foundation compile latency --- .../ghostlight-dungeon/src/model_connector.rs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/ghostlight-dungeon/src/model_connector.rs b/crates/ghostlight-dungeon/src/model_connector.rs index ec12592..bf3a2a0 100644 --- a/crates/ghostlight-dungeon/src/model_connector.rs +++ b/crates/ghostlight-dungeon/src/model_connector.rs @@ -24,6 +24,7 @@ const REQUEST_EXPIRY: Duration = Duration::from_secs(150); const FAST_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(120); const BALANCED_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(180); const CAPABLE_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(300); +const WORLD_COMPILE_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(600); #[derive(Clone)] pub struct CodexConnectorModelPort { @@ -214,9 +215,10 @@ impl ModelPort for CodexConnectorModelPort { } fn attempt_timeout(&self, request: &ModelStageRequest) -> Duration { - match request.model.as_str() { - MODEL_BALANCED => BALANCED_ATTEMPT_TIMEOUT, - MODEL_CAPABLE => CAPABLE_ATTEMPT_TIMEOUT, + match (request.stage.as_str(), request.model.as_str()) { + ("world_compile", MODEL_CAPABLE) => WORLD_COMPILE_ATTEMPT_TIMEOUT, + (_, MODEL_BALANCED) => BALANCED_ATTEMPT_TIMEOUT, + (_, MODEL_CAPABLE) => CAPABLE_ATTEMPT_TIMEOUT, _ => FAST_ATTEMPT_TIMEOUT, } } @@ -983,7 +985,7 @@ mod tests { } #[test] - fn attempt_deadline_tracks_the_logical_model_class_not_the_stage_name() -> Result<()> { + fn foundation_compile_gets_a_bounded_stage_specific_deadline() -> Result<()> { let port = CodexConnectorModelPort::new( "127.0.0.1:4103".parse()?, "bounded-test-key".to_string(), @@ -1003,6 +1005,19 @@ mod tests { temperature: None, max_output_tokens: None, }; + assert_eq!( + port.attempt_timeout(&request), + WORLD_COMPILE_ATTEMPT_TIMEOUT + ); + + request.model = MODEL_BALANCED.to_string(); + assert_eq!(port.attempt_timeout(&request), BALANCED_ATTEMPT_TIMEOUT); + + request.model = MODEL_FAST.to_string(); + assert_eq!(port.attempt_timeout(&request), FAST_ATTEMPT_TIMEOUT); + + request.stage = "agency_compile".to_string(); + request.model = MODEL_CAPABLE.to_string(); assert_eq!(port.attempt_timeout(&request), CAPABLE_ATTEMPT_TIMEOUT); request.stage = "destination_civic_reconciliation".to_string();