mslxdff 0.1.142 → 0.1.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mslxdff",
3
- "version": "0.1.142",
3
+ "version": "0.1.143",
4
4
  "description": "测试项目,请勿使用。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,12 +33,18 @@ export function responsesToChatBody(req = {}) {
33
33
  if (req.instructions) messages.push({ role: "system", content: String(req.instructions) });
34
34
  const input = req.input;
35
35
  const items = typeof input === "string" ? [{ type: "message", role: "user", content: input }] : Array.isArray(input) ? input : [];
36
- // 加密思考往返:input 里的 reasoning item 挂到下一条 assistant 消息(thinking 跨轮必需,不能丢)
36
+ // 加密思考往返:input 里的 reasoning item 挂到下一条 assistant 消息(thinking 跨轮必需,不能丢)。
37
+ // 上游按 item id 查重:同一 reasoning item 重复出现 → 400 "Duplicate item found"(2026-09-22 实测,
38
+ // 客户端重试/重放历史时会把同一 item 存两份),故按 id 保首个、丢后续——重复项无合法语义,删了不吃亏。
37
39
  let pendingReasoning = [];
40
+ const seenReasoningIds = new Set();
38
41
  for (const it of items) {
39
42
  if (!it || typeof it !== "object") continue;
40
43
  if (it.type === "reasoning") {
41
44
  if (it.id || it.encrypted_content) {
45
+ const key = String(it.id || "");
46
+ if (key && seenReasoningIds.has(key)) continue;
47
+ if (key) seenReasoningIds.add(key);
42
48
  pendingReasoning.push({ id: it.id, encrypted_content: it.encrypted_content, summary: it.summary });
43
49
  }
44
50
  continue;
@@ -41,6 +41,10 @@ function parseToolArgs(raw) {
41
41
 
42
42
  export function toModelPrompt(messages, { dropEncrypted = false } = {}) {
43
43
  const out = [];
44
+ // 上游按 item id 查重:同一 reasoning item 重复出现 → 400 "Duplicate item found"
45
+ // (上游报错原文即要求 Remove duplicate items)。这里按 itemId 保首个、丢后续,
46
+ // 防客户端重放/其他生产者把同一加密 item 组装两次。
47
+ const seenReasoningIds = new Set();
44
48
  for (const m of Array.isArray(messages) ? messages : []) {
45
49
  if (!m || typeof m !== "object") continue;
46
50
  const role = String(m.role || "");
@@ -61,6 +65,10 @@ export function toModelPrompt(messages, { dropEncrypted = false } = {}) {
61
65
  let pushedEncrypted = false;
62
66
  for (const r of items) {
63
67
  if (!r || typeof r !== "object") continue;
68
+ // 重复 id 的加密 item 直接跳过:上游按 item id 查重(Duplicate item found 400),
69
+ // 重复项无合法语义,保首个即可(首个已带全量 encrypted_content)。
70
+ if (r.id && seenReasoningIds.has(String(r.id))) continue;
71
+ if (r.id) seenReasoningIds.add(String(r.id));
64
72
  const summaryText = Array.isArray(r.summary) ? r.summary.map((s) => s?.text || "").join("\n") : "";
65
73
  if (dropEncrypted) {
66
74
  if (summaryText) parts.push({ type: "reasoning", text: summaryText });