Luxe 0.1.2: Windows fixes, working compaction, and compaction progress in the dock
This commit is contained in:
@@ -215,6 +215,27 @@ pub fn clamp_max_tokens_to_context(
|
||||
Some(capped)
|
||||
}
|
||||
|
||||
/// Output allowance for one summary, before the model's limit and the window cut it down.
|
||||
///
|
||||
/// Room for the seven sections over a whole window's worth of transcript *and* for the reasoning a
|
||||
/// model that always thinks spends first: that comes out of the same allowance, and a summary that
|
||||
/// hits the ceiling is refused whole, so a tight one fails every time on exactly the long sessions
|
||||
/// that need it.
|
||||
pub(crate) const SUMMARY_MAX_TOKENS: u32 = 16_384;
|
||||
|
||||
/// What one summary request may ask for: [`SUMMARY_MAX_TOKENS`], within `model`'s own output limit
|
||||
/// (0 for unknown) and what `prompt_tokens` leaves of its window.
|
||||
pub(crate) fn summary_max_tokens(
|
||||
model: &crate::provider::ModelInfo,
|
||||
prompt_tokens: u64,
|
||||
) -> Option<u32> {
|
||||
let ceiling = match model.max_tokens {
|
||||
0 => SUMMARY_MAX_TOKENS,
|
||||
limit => limit.min(SUMMARY_MAX_TOKENS),
|
||||
};
|
||||
clamp_max_tokens_to_context(model.context_window, prompt_tokens, ceiling)
|
||||
}
|
||||
|
||||
/// Percent of the usable window currently occupied. Returns 0.0 when either input is 0 (e.g. no
|
||||
/// usage observed yet), so callers read "unknown" as empty rather than full.
|
||||
pub fn context_fullness_percent(used_tokens: u64, usable: u64) -> f64 {
|
||||
|
||||
@@ -43,6 +43,27 @@ fn the_output_cap_never_claims_room_the_prompt_is_using() {
|
||||
assert_eq!(clamp(8_192, 999_999, 32_000), Some(MIN_MAX_TOKENS));
|
||||
}
|
||||
|
||||
/// A summary gets room to think and then write, within the model's limit and the window.
|
||||
#[test]
|
||||
fn a_summary_gets_room_beyond_what_reasoning_spends() {
|
||||
let model = |context_window, max_tokens| crate::provider::ModelInfo {
|
||||
context_window,
|
||||
max_tokens,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Fails if the allowance drops back to where thinking alone could exhaust it
|
||||
let roomy = summary_max_tokens(&model(1_000_000, 128_000), 880_000).expect("a cap");
|
||||
assert!(roomy >= 16_000, "{roomy}");
|
||||
// Fails if the model's own output limit is ignored
|
||||
assert_eq!(summary_max_tokens(&model(1_000_000, 8_000), 10_000), Some(8_000));
|
||||
// An unknown limit is no limit of its own
|
||||
assert_eq!(summary_max_tokens(&model(1_000_000, 0), 10_000), Some(SUMMARY_MAX_TOKENS));
|
||||
// Fails if the window clamp is skipped
|
||||
let tight = 200_000 - 190_000 - CONTEXT_SAFETY_TOKENS;
|
||||
assert_eq!(summary_max_tokens(&model(200_000, 128_000), 190_000), Some(tight));
|
||||
}
|
||||
|
||||
/// The prompt figure the clamp runs on: measured where the provider told us, estimated only
|
||||
/// for the tail it never saw.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user