mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 04:50:22 +08:00
fix(net-scope): region gate denial 改为紧致 stream 记录
Fixes the host crash in #84. denialStream 原先写入 4 条裸 chunk(block-start/text-delta/block-end/finish)。dsh-llm firstRunMemberTime 只认 chunk/text-chunks/reasoning-chunks/tool-call-chunks,裸记录没有 .texts,append 当下 TypeError 被当成 fatal load failure,systemd Restart=always 后 web token 一直变。现包成 { type: chunk, time, chunk },与 AssistantStreamAccumulator 一致。不改写历史 session.v4.jsonl.zstd。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
342baaed78
commit
3df4f489b1
1 file changed
+24
-1
+24
-1
@@ -450,7 +450,14 @@ async function denialMessage() {
|
||||
};
|
||||
}
|
||||
|
||||
function denialStream() {
|
||||
const COMPACT_STREAM_TYPES = new Set([
|
||||
"chunk",
|
||||
"text-chunks",
|
||||
"reasoning-chunks",
|
||||
"tool-call-chunks",
|
||||
]);
|
||||
|
||||
function denialChunks() {
|
||||
return [
|
||||
{ type: "block-start", index: 0, blockType: "text" },
|
||||
{ type: "text-delta", index: 0, text: DENIAL },
|
||||
@@ -459,6 +466,22 @@ function denialStream() {
|
||||
];
|
||||
}
|
||||
|
||||
/** 宿主持久化只要 Accumulator 紧致记录;裸 chunk 会让 firstRunMemberTime 读 undefined.length(#84)。 */
|
||||
function denialStream(now = Date.now()) {
|
||||
const time0 = Number.isSafeInteger(now) ? now : Date.now();
|
||||
const stream = denialChunks().map((chunk, i) => ({
|
||||
type: "chunk",
|
||||
time: time0 + i,
|
||||
chunk,
|
||||
}));
|
||||
for (const record of stream) {
|
||||
if (!record || !COMPACT_STREAM_TYPES.has(record.type)) {
|
||||
throw new TypeError("denial stream must use compact Assistant records");
|
||||
}
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
async function appendDenial(session, turn, step) {
|
||||
session.append("assistant/message", {
|
||||
turn,
|
||||
|
||||
Reference in new issue
Block a user