Fix usage records filtering and pool trace display

This commit is contained in:
fawney19
2026-05-28 20:24:48 +08:00
parent df518ad668
commit ef2953038e
11 changed files with 309 additions and 15 deletions
@@ -795,6 +795,10 @@ impl<'a> PoolKeyCursor<'a> {
if self.skip_candidate_if_runtime_cooldown(&candidate).await {
continue;
}
if candidate.orchestration.candidate_group_id.is_none() {
candidate.orchestration.candidate_group_id =
Some(pool_cursor_candidate_group_id(&self.group));
}
candidate.orchestration.pool_key_index = Some(self.next_pool_key_index);
self.next_pool_key_index = self.next_pool_key_index.saturating_add(1);
return Some(candidate);
@@ -1539,6 +1543,17 @@ fn pool_candidate_facts(candidate: &EligibleLocalExecutionCandidate) -> PoolCand
}
}
fn pool_cursor_candidate_group_id(group: &EligibleLocalExecutionCandidate) -> String {
format!(
"provider={}|endpoint={}|model={}|selected_model={}|api_format={}|singleton_key=*",
group.candidate.provider_id,
group.candidate.endpoint_id,
group.candidate.model_id,
group.candidate.selected_provider_model_name,
group.provider_api_format,
)
}
fn pool_scheduling_config(
config: AdminProviderPoolConfig,
provider_type: &str,
@@ -2813,6 +2828,12 @@ mod tests {
.expect("cursor should skip disallowed pool key and return allowed key");
assert_eq!(candidate.candidate.key_id, "key-b");
assert_eq!(candidate.orchestration.pool_key_index, Some(0));
assert_eq!(
candidate.orchestration.candidate_group_id.as_deref(),
Some(
"provider=provider-pool|endpoint=endpoint-1|model=model-1|selected_model=gpt-5|api_format=openai:chat|singleton_key=*"
)
);
assert_eq!(
cursor
.skip_reason_counts