Give capable connector stages their provider window

This commit is contained in:
Meta Vens 2026-08-27 16:53:07 +02:00
commit 78f3d67c17
2 changed files with 40 additions and 18 deletions

View file

@ -7,10 +7,7 @@ use crate::{
LocalityElaborationPreview, Location, MAX_POSTURE_CHARS, Route, VaultEvidenceReceipt,
WorldClock, WorldCompilePreview, WorldFact,
},
model::{
ModelPort, ModelStageReceipt, ModelStageRequest, run_validated_stage,
run_validated_stage_with_timeout,
},
model::{ModelPort, ModelStageReceipt, ModelStageRequest, run_validated_stage},
session_zero::{
ApprovedCampaignBrief, CampaignContract, MAX_SESSION_ZERO_MEMBERS, actor_from_character,
},
@ -2680,16 +2677,7 @@ impl WorldCompiler {
_ => 2_500,
}),
};
let out = if stage == "world_compile" {
run_validated_stage_with_timeout(
self.model.as_ref(),
&request,
std::time::Duration::from_secs(120),
)
.await?
} else {
run_validated_stage(self.model.as_ref(), &request).await?
};
let out = run_validated_stage(self.model.as_ref(), &request).await?;
Ok((
out.structured
.ok_or_else(|| anyhow!("compiler returned no structured output"))?,

View file

@ -15,11 +15,13 @@ use tokio::sync::Semaphore;
use zeroize::Zeroizing;
use crate::model::{
MODEL_CAPABLE, ModelPort, ModelProviderOutput, ModelStageRequest, ModelTokenUsage,
MODEL_CAPABLE, MODEL_FAST, ModelPort, ModelProviderOutput, ModelStageRequest, ModelTokenUsage,
};
const MAX_FRAME_BYTES: usize = 1_052_672;
const REQUEST_EXPIRY: Duration = Duration::from_secs(150);
const FAST_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(120);
const CAPABLE_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(300);
#[derive(Clone)]
pub struct CodexConnectorModelPort {
@ -83,7 +85,7 @@ impl CodexConnectorModelPort {
fn invoke(&self, request: &ModelStageRequest) -> Result<ModelProviderOutput> {
let request_id = format!("ghostlight-model-{}", uuid::Uuid::new_v4());
let resolved_model = match request.model.as_str() {
crate::model::MODEL_FAST => self.fast_model.clone(),
MODEL_FAST => self.fast_model.clone(),
MODEL_CAPABLE => self.capable_model.clone(),
explicit => explicit.to_string(),
};
@ -153,8 +155,12 @@ impl ModelPort for CodexConnectorModelPort {
"codex-connector"
}
fn attempt_timeout(&self, _request: &ModelStageRequest) -> Duration {
Duration::from_secs(120)
fn attempt_timeout(&self, request: &ModelStageRequest) -> Duration {
if request.model == MODEL_CAPABLE {
CAPABLE_ATTEMPT_TIMEOUT
} else {
FAST_ATTEMPT_TIMEOUT
}
}
}
@ -695,6 +701,34 @@ mod tests {
assert!(error.contains("sibling keywords beside $ref"));
}
#[test]
fn attempt_deadline_tracks_the_logical_model_class_not_the_stage_name() -> Result<()> {
let port = CodexConnectorModelPort::new(
"127.0.0.1:4103".parse()?,
"bounded-test-key".to_string(),
"ghostlight-test",
"gpt-5.6-luna",
"gpt-5.6-sol",
1,
)?;
let mut request = ModelStageRequest {
stage: "world_compile".to_string(),
model: MODEL_CAPABLE.to_string(),
snapshot_binding: "revision:0".to_string(),
lived_stream: "fixture".to_string(),
output_schema: None,
source_receipt_ids: Vec::new(),
temperature: None,
max_output_tokens: None,
};
assert_eq!(port.attempt_timeout(&request), CAPABLE_ATTEMPT_TIMEOUT);
request.stage = "cell_interpreter".to_string();
request.model = MODEL_FAST.to_string();
assert_eq!(port.attempt_timeout(&request), FAST_ATTEMPT_TIMEOUT);
Ok(())
}
#[test]
fn cache_key_tracks_stable_stage_contract_not_dynamic_world_context() -> Result<()> {
let request = ModelStageRequest {