pub async fn derive_with_policy(
session: &Session,
provider: Arc<dyn Provider>,
model: &str,
system_prompt: &str,
tools: &[ToolDefinition],
event_tx: Option<&Sender<SessionEvent>>,
policy: DerivePolicy,
force_keep_last: Option<usize>,
) -> Result<DerivedContext>Expand description
Derive an ephemeral DerivedContext under a chosen DerivePolicy.
Generalisation of derive_context that accepts a policy selector.
DerivePolicy::Legacy delegates back to derive_context so the
two signatures co-exist without behaviour drift during rollout.
§Arguments
Same as derive_context, plus:
policy— Which derivation strategy to run. SeeDerivePolicy.force_keep_last— WhenSome(n), bypass policy selection and fall back to the legacy keep-last derivation used for prompt-too-long recovery.
§Errors
Propagates any error from the underlying pipeline.