Files
genoffice/apps
konghaojie-k2 f105f366e2 feat ai settings for the per-turn output token cap (#185)
Every app's AI IPC handler computed `request.maxTokens ?? 8192`, and no
renderer ever sends maxTokens — so the per-turn output budget was a
hardcoded 8192 that BYOK users could not change. For a reasoning model
that cap is shared with thinking: probed against api.deepseek.com/v1 with
max_tokens=3000, usage came back completion_tokens=3000 /
reasoning_tokens=3000 with zero content deltas and finish_reason=length,
i.e. the model never started answering. At the observed ~129 tok/s the
8192 default is exactly the ~60s "empty reply" users reported.

Thinking cannot simply be switched off for these models: registry.ts pins
the *direct* deepseek endpoint to non-thinking because its transcript
could not round-trip reasoning, while modelEchoesReasoning() documents
that DeepSeek V4 rejects tool turns unless the reasoning is echoed back.
So the honest lever is the budget, not the switch.

- AiSettings.maxOutputTokens (absent = default, so existing settings
  files keep behaving identically), clamped to [1024, 131072] when read
  and when typed: a hand-edited or mistyped value can never be forwarded
  to an endpoint verbatim.
- docs/sheets/slides main handlers resolve the cap through
  maxOutputTokensOf(settings); markdown and pdf share docs' ai:stream
  channel, so all six apps follow the setting from one place.
- Settings ▸ AI model: a numeric field (clamped on blur) labelled in all
  19 languages.
- sheets' aiSettingsInputSchema is .strict(), so it had to learn the key
  or saving settings would have started failing.
2026-09-03 14:58:48 +08:00
..