2026-04-09 00:10:38 +08:00
|
|
|
use aether_scheduler_core::SchedulerMinimalCandidateSelectionCandidate;
|
|
|
|
|
use serde_json::Value;
|
|
|
|
|
|
|
|
|
|
use super::PlannerAppState;
|
|
|
|
|
|
|
|
|
|
impl<'a> PlannerAppState<'a> {
|
2026-04-10 01:46:14 +08:00
|
|
|
pub(crate) async fn resolve_request_candidate_required_capabilities(
|
|
|
|
|
self,
|
|
|
|
|
user_id: &str,
|
|
|
|
|
api_key_id: &str,
|
|
|
|
|
requested_model: Option<&str>,
|
|
|
|
|
explicit_required_capabilities: Option<&Value>,
|
|
|
|
|
) -> Option<Value> {
|
2026-05-03 14:48:25 +08:00
|
|
|
let enable_model_directives =
|
|
|
|
|
crate::system_features::reasoning_model_directive_enabled(self.app()).await;
|
2026-04-10 01:46:14 +08:00
|
|
|
crate::request_candidate_runtime::resolve_request_candidate_required_capabilities(
|
|
|
|
|
self.app(),
|
|
|
|
|
user_id,
|
|
|
|
|
api_key_id,
|
|
|
|
|
requested_model,
|
|
|
|
|
explicit_required_capabilities,
|
2026-05-03 14:48:25 +08:00
|
|
|
enable_model_directives,
|
2026-04-10 01:46:14 +08:00
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-09 00:10:38 +08:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
|
pub(crate) async fn persist_available_local_candidate(
|
|
|
|
|
self,
|
|
|
|
|
trace_id: &str,
|
|
|
|
|
user_id: &str,
|
|
|
|
|
api_key_id: &str,
|
|
|
|
|
candidate: &SchedulerMinimalCandidateSelectionCandidate,
|
|
|
|
|
candidate_index: u32,
|
2026-04-18 11:35:11 +08:00
|
|
|
retry_index: u32,
|
2026-04-09 00:10:38 +08:00
|
|
|
candidate_id: &str,
|
2026-04-10 01:46:14 +08:00
|
|
|
required_capabilities: Option<&Value>,
|
2026-04-09 00:10:38 +08:00
|
|
|
extra_data: Option<Value>,
|
2026-04-10 01:46:14 +08:00
|
|
|
created_at_unix_ms: u64,
|
2026-04-09 00:10:38 +08:00
|
|
|
error_context: &'static str,
|
|
|
|
|
) -> String {
|
|
|
|
|
crate::request_candidate_runtime::persist_available_local_candidate(
|
|
|
|
|
self.app(),
|
|
|
|
|
trace_id,
|
|
|
|
|
user_id,
|
|
|
|
|
api_key_id,
|
|
|
|
|
candidate,
|
|
|
|
|
candidate_index,
|
2026-04-18 11:35:11 +08:00
|
|
|
retry_index,
|
2026-04-09 00:10:38 +08:00
|
|
|
candidate_id,
|
2026-04-10 01:46:14 +08:00
|
|
|
required_capabilities,
|
2026-04-09 00:10:38 +08:00
|
|
|
extra_data,
|
2026-04-10 01:46:14 +08:00
|
|
|
created_at_unix_ms,
|
2026-04-09 00:10:38 +08:00
|
|
|
error_context,
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
|
pub(crate) async fn persist_skipped_local_candidate(
|
|
|
|
|
self,
|
|
|
|
|
trace_id: &str,
|
|
|
|
|
user_id: &str,
|
|
|
|
|
api_key_id: &str,
|
|
|
|
|
candidate: &SchedulerMinimalCandidateSelectionCandidate,
|
|
|
|
|
candidate_index: u32,
|
2026-04-18 11:35:11 +08:00
|
|
|
retry_index: u32,
|
2026-04-09 00:10:38 +08:00
|
|
|
candidate_id: &str,
|
2026-04-10 01:46:14 +08:00
|
|
|
required_capabilities: Option<&Value>,
|
2026-04-09 00:10:38 +08:00
|
|
|
skip_reason: &str,
|
2026-04-14 11:50:52 +08:00
|
|
|
extra_data: Option<Value>,
|
2026-04-10 01:46:14 +08:00
|
|
|
finished_at_unix_ms: u64,
|
2026-04-09 00:10:38 +08:00
|
|
|
error_context: &'static str,
|
|
|
|
|
) {
|
|
|
|
|
crate::request_candidate_runtime::persist_skipped_local_candidate(
|
|
|
|
|
self.app(),
|
|
|
|
|
trace_id,
|
|
|
|
|
user_id,
|
|
|
|
|
api_key_id,
|
|
|
|
|
candidate,
|
|
|
|
|
candidate_index,
|
2026-04-18 11:35:11 +08:00
|
|
|
retry_index,
|
2026-04-09 00:10:38 +08:00
|
|
|
candidate_id,
|
2026-04-10 01:46:14 +08:00
|
|
|
required_capabilities,
|
2026-04-09 00:10:38 +08:00
|
|
|
skip_reason,
|
2026-04-14 11:50:52 +08:00
|
|
|
extra_data,
|
2026-04-10 01:46:14 +08:00
|
|
|
finished_at_unix_ms,
|
2026-04-09 00:10:38 +08:00
|
|
|
error_context,
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
}
|