fix(tokens): generalize Gemini context-window detection by tier
windowByModelFamily matched Gemini models by exact version substring
("gemini-1.5-pro", "gemini-1.5-flash", "gemini-2"), so any newer
generation (3.x and beyond) fell through to defaultRemoteUnknownWindow
(128k) purely because this table hadn't been updated yet — observed
via hand's status line showing a >100% context gauge for a
"gemini-3.8-flash"-family model whose real window is far larger, and
which made harness's own preventive compaction unreachable (the
threshold check never fires against a window this far off).
Match on tier (Pro vs. everything else) instead of enumerating every
version: every Pro-tier Gemini release so far ships 2M, everything
else at least 1M, and both hold for a model this table has never seen
the exact version string of.
This commit is contained in:
1 parent
986c233d39
commit
0ba1b4dbcc
2 files changed
+40
-3
No files matched your search
+17
-3
@@ -141,10 +141,24 @@ func windowByModelFamily(modelID string) int {
|
||||
return 8192
|
||||
case strings.HasPrefix(leaf, "gpt-3.5"):
|
||||
return 16385
|
||||
case strings.Contains(id, "gemini-1.5-pro"):
|
||||
case strings.Contains(id, "gemini") && strings.Contains(id, "pro"):
|
||||
// Every "Pro"-tier Gemini release so far (1.5 Pro onward) has
|
||||
// shipped the largest window in its generation. Matching on the
|
||||
// tier rather than enumerating each version keeps a future Pro
|
||||
// release (2.5, 3, ...) from falling through to the
|
||||
// flash/other-tier case below, let alone all the way to
|
||||
// defaultRemoteUnknownWindow.
|
||||
return 2000000
|
||||
case strings.Contains(id, "gemini-1.5-flash"),
|
||||
strings.Contains(id, "gemini-2"):
|
||||
case strings.Contains(id, "gemini"):
|
||||
// Every non-Pro Gemini model since 1.5 (Flash and other tiers)
|
||||
// has shipped at least a 1M window. Matching on the family alone
|
||||
// — not "gemini-1.5-flash"/"gemini-2" by exact version — means a
|
||||
// new Gemini generation (3.x and beyond) gets a realistic window
|
||||
// immediately instead of silently falling back to
|
||||
// defaultRemoteUnknownWindow (128k), which made preventive
|
||||
// compaction fire far too early and the context-usage gauge
|
||||
// read a nonsensical >100% for a model this table simply hadn't
|
||||
// been updated for yet.
|
||||
return 1000000
|
||||
}
|
||||
return 0
|
||||
|
||||
Reference in new issue
Block a user