fix(tui): handle fixed-sampling compaction and report post-compaction context - #19
Conversation
|
Thanks @qiuYliangM for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
|
I pushed two corrective commits after reviewing the full route and host contracts:
The resulting implementation:
I initially explored a larger model-specific context-clamp/provenance change, but removed it before committing. The final supplement reuses the existing roster, route predicate, model metadata, and operator override paths; no new foundation abstraction was added. Validation completed:
The dependent Pinvou/pinvou-agent#322 gitlink should be finalized only after this PR lands, using the resulting commit that is reachable from |
|
Verified the fixed-sampling claims against the live endpoints with real first-party credentials (results from today, 2026-08-25): DeepSeek official endpoint — 400 not reproducible anywhere
So the original commit message's claim that the official DeepSeek v4 routes reject non-1 temperature does not hold today. Either the provider relaxed the constraint after 2026-08-19, or the observed 400 was misattributed. Consequences for this revision:
Kimi Code membership route — 400 reproduced exactly
So the real fixed-sampling route is the Kimi Code membership route, and the exact-ID allowlist ( Minor: the Cross-repo heads-up: the host wiring in pinvou-agent PR Hmbown#322 currently pins the CodeWhale gitlink to |
DeepSeek 官方端点 v4 系列与 Kimi Code 会员路由 kimi-for-coding 系列 的采样参数被固定(temperature 只允许 1),compaction 等辅助调用硬编码 temperature 0.3 在这些路由必现 400 "only 1 is allowed for this model" ——正常聊天不显式携带 temperature 所以不受影响,表现为聊天正常、 一点压缩就炸,自动压缩到达阈值后同样失败,长会话无法续命。 修复在出站侧按精确路由剥离:Chat 方言在 build_chat_wire_body seam 新增 apply_deepseek_v4_official_fixed_sampling 与 apply_kimi_code_coding_plan_fixed_sampling;Responses 方言在 build_responses_body_for_provider 对 v4 模型剥离非 1 值。中转网关、 旧代模型与其他 provider 的 wire 契约不动。 新增 forkguard_deepseek_v4_official_route_strips_fixed_temperature、 forkguard_deepseek_v4_responses_drops_non_one_temperature 与 forkguard_kimi_code_coding_plan_strips_non_one_temperature 锁定行为。 Signed-off-by: luzeyang (INT) <lu.zeyang@h3c.com>
新增 post_input_tokens 字段:emit_compaction_completed 在 replace_messages 之后对压缩后的新消息列表做保守估算 (estimate_input_tokens_conservative,不含 system prompt)。 宿主(pinvou3 代码页用量 chip)靠它在压缩完成后立即刷新展示的 上下文占用;此前只能等下一轮对话的真实 usage,期间一直显示压缩前 的旧值。TUI 与 runtime thread 持久化路径不消费该字段。 Signed-off-by: luzeyang (INT) <lu.zeyang@h3c.com>
Preserve the documented DeepSeek Chat sampling contract while limiting the observed Responses compatibility shim to the exact V4-Flash model. Keep Kimi fixed sampling on the two known K2.7 membership IDs and exact first-party route. Emit the engine's complete post-compaction input estimate, including the system prompt, and cover route lookalikes, unknown model IDs, and the host event value with regression tests. Signed-off-by: hexin <he.xin@h3c.com>
Signed-off-by: hexin <he.xin@h3c.com>
7f1a592 to
ad3f26b
Compare
|
Follow-up: the branch was based on One note on the K3 commit: the membership allowlist grew to four IDs ( |
|
/lgtm |
|
@qiuYliangM is already approved for pr contributions in |
Background
Compaction requests use an explicit
temperature: 0.3. The Kimi Code membership route rejected that value forkimi-for-coding, so manual and automatic compaction could fail while normal chat continued to work. Kimi Code's current official roster also includes the K3 IDsk3andk3-256k, which share the membership route's fixed-sampling contract.The Pinvou host also needs a post-compaction context estimate immediately; otherwise its usage chip keeps showing the stale pre-compaction value until another provider usage event arrives.
Changes
temperatureandtop_pfor the four documented membership IDs:k3,k3-256k,kimi-for-coding, andkimi-for-coding-highspeed. Custom gateways and unknown/future IDs remain untouched.k3-256kas a first-class Kimi Code model with the K3 nested reasoning contract, a 262,144-token static context window, and a conservative 131,072-token output ceiling.k3separate for membership-plan context handling: only barek3can enter the existing 1M plan-tier/provider-metadata path;k3-256kuses the ordinary fixed model metadata path.k3-256kis not misread as 256,000 tokens.deepseek-v4-flashResponses route. DeepSeek Chat preserves the documented temperature field, including on custom and lookalike hosts.CompactionCompleted.post_input_tokensusing the engine canonical complete input estimate, including the system prompt and accumulated compaction summary.Validation
cargo fmt --all -- --checkcargo test -p codewhale-tui --lib --locked kimi_code— 48 passedcargo test -p codewhale-tui --lib --locked forkguard_— 27 passedcargo test -p codewhale-tui --lib --locked models::tests— 27 passedcargo check -p codewhale-tui --locked— passedKnown risks
k3-256kgets the documented 262,144-token static model fact and does not inherit barek3's automatic 1M entitlement path. The existing explicitcontext_windowoperator override remains authoritative; this PR deliberately does not add a model-specific clamp or new limit-provenance machinery.No-Issue: repository Issues are disabled (creation returns 410); the reproduction and validation evidence are recorded above.