Skip to content

Commit 37fd880

Browse files
fix(module): nudge copy quotes the host usableSoft window (872k), not the usage-reported scheduler denominator (1000k) — parity hunt #2; differ gains thinking/nudge/system axes
Co-authored-by: Alfonso <[email protected]>
2 parents 169c598 + 1b7648a commit 37fd880

3 files changed

Lines changed: 699 additions & 11 deletions

File tree

‎crates/mc-module/src/transform.rs‎

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5200,7 +5200,10 @@ fn apply_once(
52005200
if let Some(row) = maybe_append_channel1_nudge(
52015201
Channel1NudgeInputs {
52025202
ctx,
5203-
usable_window_tokens: context_limit_tokens.round() as i64,
5203+
usable_window_tokens: effective_nudge_window_tokens(
5204+
req.geometry.as_ref(),
5205+
context_limit_tokens,
5206+
),
52045207
core: &core,
52055208
projection: &projection,
52065209
tag_rows: &hygiene_tag_rows,
@@ -5397,7 +5400,10 @@ fn apply_once(
53975400
&req.channel2_nudge_state,
53985401
ctx.now_ms,
53995402
Channel2DirectiveInput {
5400-
usable_window_tokens: context_limit_tokens.round() as i64,
5403+
usable_window_tokens: effective_nudge_window_tokens(
5404+
req.geometry.as_ref(),
5405+
context_limit_tokens,
5406+
),
54015407
core: &core,
54025408
projection: &projection,
54035409
tag_rows: &hygiene_tag_rows,
@@ -5799,6 +5805,20 @@ fn effective_context_limit_tokens(
57995805
200_000.0
58005806
}
58015807

5808+
fn effective_nudge_window_tokens(
5809+
geometry: Option<&TransformGeometry>,
5810+
scheduler_context_limit_tokens: f64,
5811+
) -> i64 {
5812+
// Keep the usage-reported context limit for scheduler calculations. Reminder text describes
5813+
// context available after host reserves, so prefer the host's `usable_soft` geometry.
5814+
geometry
5815+
.filter(|geometry| geometry.usable_soft >= crate::scheduler::MIN_PLAUSIBLE_CONTEXT_LIMIT)
5816+
.map_or(scheduler_context_limit_tokens, |geometry| {
5817+
geometry.usable_soft as f64
5818+
})
5819+
.round() as i64
5820+
}
5821+
58025822
fn effective_hard_context_limit_tokens(
58035823
geometry: Option<&TransformGeometry>,
58045824
soft_context_limit_tokens: f64,
@@ -13429,6 +13449,30 @@ pub(crate) mod tests {
1342913449
);
1343013450
}
1343113451

13452+
#[test]
13453+
fn nudge_display_denominator_prefers_geometry_usable_soft() {
13454+
let geometry = TransformGeometry {
13455+
usable_soft: 872_000,
13456+
usable_hard: 1_000_000,
13457+
derivation: "models.dev/1000000; usableSoft=872000".to_string(),
13458+
};
13459+
let scheduler_denominator = effective_context_limit_tokens(
13460+
&ModuleUsage {
13461+
current_total_input_tokens: 600_000,
13462+
context_limit_tokens: 1_000_000,
13463+
..ModuleUsage::default()
13464+
},
13465+
Some(&geometry),
13466+
);
13467+
13468+
assert_eq!(scheduler_denominator, 1_000_000.0);
13469+
assert_eq!(
13470+
effective_nudge_window_tokens(Some(&geometry), scheduler_denominator),
13471+
872_000
13472+
);
13473+
assert_eq!(effective_nudge_window_tokens(None, 128_000.0), 128_000);
13474+
}
13475+
1343213476
#[test]
1343313477
fn absent_geometry_falls_back_to_the_soft_usage_denominator() {
1343413478
let soft = 128_000.0;

0 commit comments

Comments
 (0)