822f2b304 (#2823) held the maxTokens magpie lists for dsh to a quarter
of the window, because dsh reserves it, plus 65536 of headroom, before
it compacts (compaction-basic's resolveCompactSpec: threshold = min(0.8W,
W - maxTokens - 65536)). On a large window the quarter cut more than
compaction needs: DeepSeek's own deepseek-flash, 1000000/393216, was
listed at 250000, though all 393216 leaves dsh 541248 (54%).
Now the cap is max(W/4, W/2 - 65536): the output may take what leaves
dsh half the window to compact in, or a quarter of the window where that
is more (every window under 262144, where there is no half to spare
beside the headroom). A Max output the user set is still written as set
(outputOr), and contextWindow and /v1/models don't change.
dsh 0.2.0-rc.2's own resolveCompactSpec, run on the installed
compaction-basic over each figure (threshold tokens):
| window / output | vendor | quarter (main) | now |
| 524288 / 524288 | no message budget | 131072 -> 327680 | 196608 -> 262144 |
| 500000 / 393216 (#2823) | 41248 | 125000 -> 309464 | 184464 -> 250000 |
| 131072 / 65536 | no pressure budget | 32768 -> 32768 | 32768 -> 32768 |
| 1000000 / 393216 | 541248 | 250000 -> 684464 | 393216 -> 541248 |
| 400000 / 128000 | 206464 | 100000 -> 234464 | 128000 -> 206464 |
| 200000 / 393216 | no message budget | 50000 -> 84464 | 50000 -> 84464 |
| 128000 / 393216 | no message budget | 32000 -> 30464 | 32000 -> 30464 |
#2823's case stays fixed: 250000 is half its 500000 window (its
reporter's own plan A), against 41248 before 822f2b304; it is lower than
the quarter's 309464, which is the trade. The 128K and 200K windows
#3298 names don't change: any output above the quarter there takes it
straight out of what dsh compacts at, and a user who wants more sets Max
output.
Tests: TestDshOutputLeavesCompactionRoom's table takes the new figures
and adds DeepSeek's 1000000/393216 (393216), 200000 and 128000 windows;
its check now holds dsh's threshold at half the window where the window
has one, never under what a quarter leaves. TestDshModelLimits'
400000/128000 is now 128000; TestMaxTokensWithinContextWindow's dsh
figure follows the formula (its windows are all under 262144). Broken by
hand: the quarter alone (main) is red on 4 cases ("maxTokens 250000;
want ... 393216"), W/2 - 65536 alone on 3 (131072 gets 1), no cap
(pre-#2823) on #2823's own cases (524288/524288, 524288/1048576,
500000/393216, 131072/65536) and the 200K and 128K windows. docs/subsystems/agent-wiring.md says the new rule.
Run at 5adad1877 (this commit on top of item 4's): gofmt -l (nothing),
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... (all clean), go build for darwin, linux (nogui) and windows (ok),
and go test -tags nogui -timeout 45m ./...: all 69 packages ok, exit 0
(gateway 505s, agent 401s, provider 197s).
Not tried: a real DSH session against a 1M DeepSeek model through
magpie; the thresholds above come from dsh's resolveCompactSpec run
directly. Windows under ~87K (64000/384000 -> 16000) still leave dsh no
pressure budget, on main too; that needs a policy of its own and isn't
changed here.