use std::sync::Arc;
use anyhow::Result;
use tokio::sync::mpsc;
use crate::provider::ToolDefinition;
use crate::session::Session;
use crate::session::SessionEvent;
use crate::session::derive_policy::DerivePolicy;
use super::derive::derive_context;
use super::helpers::DerivedContext;
use super::reset::derive_reset;
pub async fn derive_with_policy(
session: &Session,
provider: Arc<dyn crate::provider::Provider>,
model: &str,
system_prompt: &str,
tools: &[ToolDefinition],
event_tx: Option<&mpsc::Sender<SessionEvent>>,
policy: DerivePolicy,
) -> Result<DerivedContext> {
match policy {
DerivePolicy::Legacy => {
derive_context(
session,
provider,
model,
system_prompt,
tools,
event_tx,
None,
)
.await
}
DerivePolicy::Reset { threshold_tokens } => {
derive_reset(
session,
provider,
model,
system_prompt,
tools,
threshold_tokens,
)
.await
}
}
}