Archive the request-compatibility decision and record the successful short streaming request. This does not claim long-context cancellation is resolved.
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
# Agent Note: Kimi Work 官方请求兼容性修正
|
||||||
|
|
||||||
|
Status: implemented
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
插件与当前 Kimi 官方 Work 运行时的请求契约存在差异:版本标识仍停留在旧版,推理请求缺少标准上下文长度、Work 标记和追踪头;导入账号没有稳定的设备 ID;调用方可以把超过模型目录上限的 `max_tokens` 发往上游。慢首字排查无法在一个请求契约不一致的插件上得到可靠结论。
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
按本机 Kimi 3.2.28、daimon 1.0.14、Kimi Code 0.5.1 的实际运行时对齐版本标识和默认请求头。标准上下文默认发送 `X-Kimi-Context-Length: 262144`,调用方显式提供的值优先;推理请求补 `traceparent` 与 `X-KimiWork-Tag: normal`。
|
||||||
|
|
||||||
|
本机登录继续优先使用官方 `device_id`。粘贴导入允许用户额外填写该文件中的 UUID,直接文件导入或未填写时按账号 UID 用 RFC URL 命名空间生成 UUIDv5,使同一账号跨插件版本、跨安装得到同一值。旧导入账号在请求时推导该值,无需重新登录或迁移认证记录。
|
||||||
|
|
||||||
|
`max_tokens` 和 `max_completion_tokens` 只在超过模型目录的输出上限时收紧,较小值和不透明 body 保持不变。`prompt_cache_key`、消息、工具、流式参数继续透传,不增加自动重试,也不修改调用方超时。
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
插件与当前官方客户端的公开请求标识和默认上下文契约保持一致,同时保留调用方对 XL 和已有追踪头的显式选择。账号级确定性 UUID 的代价是多台 Magpie 在上游表现为同一设备,可能失去设备级排障和隔离能力;需要与桌面版完全一致时可在粘贴导入中填写官方 ID。
|
||||||
|
|
||||||
|
这次修正解决的是已确认的请求差异,不等同于证明慢首字或 180 秒客户端取消已经根除。长上下文仍可能增加上游排队和首 token 时间。
|
||||||
|
|
||||||
|
## Alternatives considered
|
||||||
|
|
||||||
|
只提示用户粘贴官方设备 ID 最接近本机桌面行为,但直接文件导入无法交互,旧账号也需要重新登录,不能满足跨版本稳定且零迁移成本的要求。
|
||||||
|
|
||||||
|
按机器生成随机 ID 能区分物理设备,但同一账号换机器或重装插件后标识会变化,不符合账号级稳定标识的要求。
|
||||||
|
|
||||||
|
总是发送 XL 上下文可以避免标准长度与长请求不一致,但会未经用户选择启用更高消耗的 XL 模式,因此默认只对齐官方 Standard,并允许调用方显式覆盖。
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
`node --check packages/kimi-work/index.mjs` 通过;`npx --yes bun test packages/kimi-work` 为 117 通过、0 失败;`npx --yes bun scripts/check.mjs kimi-work` 通过。测试覆盖版本头、稳定设备 ID、标准/XL 上下文头覆盖、Work 标记、traceparent、输出 token 限制,以及旧导入账号无 `deviceId` 字段时的免迁移请求。
|
||||||
|
|
||||||
|
Gitea 提交 `8430d83306a0c5d7e56a96bc2909b32999a2ddc6` 已安装到 NAS 的 Magpie v0.1.4384 容器,目录为 `/config/magpie/custom-plugins/kimi-work-0.1.19`,旧 0.1.18 条目关闭且文件保留。2026-11-20 的最小真实流式请求返回 HTTP 200、SSE 内容帧和 `[DONE]`,首响应字节约 3.008 秒、总耗时约 6.863 秒。该样本不证明长上下文或 180 秒取消场景已解决。
|
||||||
@@ -12,7 +12,9 @@ The Work gateway's explicit client identifiers now match the installed official
|
|||||||
|
|
||||||
Local accounts prefer the desktop's official `device_id`. Imported accounts can retain an explicitly pasted official UUID or use a deterministic UUIDv5 derived from the account UID in the RFC URL namespace. Existing imported records without the field derive it at request time. The fallback is account-scoped, not machine-scoped: multiple installations serving the same account intentionally present the same device identity.
|
Local accounts prefer the desktop's official `device_id`. Imported accounts can retain an explicitly pasted official UUID or use a deterministic UUIDv5 derived from the account UID in the RFC URL namespace. Existing imported records without the field derive it at request time. The fallback is account-scoped, not machine-scoped: multiple installations serving the same account intentionally present the same device identity.
|
||||||
|
|
||||||
The synthetic request tests verify these headers, identifier stability, and body limits. They do not by themselves establish upstream acceptance, a particular first-token latency, or resolution of client-side cancellation. XL remains opt-in through an explicit caller header; no automatic retry or timeout change is introduced.
|
The synthetic request tests verify these headers, identifier stability, and body limits. XL remains opt-in through an explicit caller header; no automatic retry or timeout change is introduced.
|
||||||
|
|
||||||
|
On **2026-11-20**, the Gitea commit `8430d83306a0c5d7e56a96bc2909b32999a2ddc6` was installed as `/config/magpie/custom-plugins/kimi-work-0.1.19` in the NAS's Magpie **v0.1.4384** container. A minimal streaming `kimi-work/k3-agent` request completed with HTTP **200**, SSE content/reasoning frames and `[DONE]`. Curl measured **3.008 s** to the first response byte (a keepalive counts as a byte) and **6.863 s** overall. The deliberate 16-token output limit ended with `finish_reason: length`, so this checks transport and upstream acceptance, not the requested exact answer text. No long-context or 180-second cancellation regression claim is made from this single short request.
|
||||||
|
|
||||||
## RefreshToken request comparison
|
## RefreshToken request comparison
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user