Commit a96f445
fix: resolve ratio base from active session model, not agent config
Audited every site that consumes the new `*Share` fields and confirmed the
context-window base is always the SESSION-active model:
- `pi-embedded-runner/run/attempt.ts` reads `params.model.contextWindow`,
where `params.model` is `effectiveModel` from `resolveEffectiveRuntimeModel`
using the per-run `provider`/`modelId` (which already honors session model
overrides via `resolveHookModelSelection` and persisted session overrides).
- `pi-embedded-runner/compact.ts` reads `model?.contextWindow` from the model
resolved by `resolveModelAsync(provider, modelId, …)` where provider/modelId
flow from `params.provider`/`params.model` (session-scoped) through
`resolveEmbeddedCompactionTarget`, with the documented `compaction.model`
override taking precedence only when explicitly configured.
- `auto-reply/reply/memory-flush.ts` resolves the window via
`resolveMemoryFlushContextWindowTokens` from `followupRun.run.model` —
the per-run model captured at queue time, which is session-scoped.
No code path computes the share against a statically baked agent-default
model, so no fix to the resolution logic is required. Documentation,
however, was implicit. This commit:
- Extends JSDoc on each `*Share` field in `types.agent-defaults.ts` to
state explicitly that the base is the context window of the model
active for the CURRENT SESSION, falling back to the agent's default
model, then to DEFAULT_CONTEXT_TOKENS.
- Adds a regression test in `reply-state.test.ts` proving that two
sessions of the same agent (one inheriting the agent default
glm-4.7@200k, one overriding to kimi-k2@1M) compute different
`reserveTokensFloor` and `softThresholdTokens` from the same share
config — locking in the session-scoped semantics so a future refactor
cannot silently regress to agent-scoped resolution.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>1 parent f22fd96 commit a96f445
2 files changed
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
519 | 586 | | |
520 | 587 | | |
521 | 588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
391 | 397 | | |
392 | 398 | | |
393 | 399 | | |
| |||
396 | 402 | | |
397 | 403 | | |
398 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
399 | 409 | | |
400 | 410 | | |
401 | 411 | | |
| |||
404 | 414 | | |
405 | 415 | | |
406 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
407 | 421 | | |
408 | 422 | | |
409 | 423 | | |
| |||
462 | 476 | | |
463 | 477 | | |
464 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
465 | 483 | | |
466 | 484 | | |
467 | 485 | | |
| |||
0 commit comments