fix(consult): drop traces, budget checkpoints, silent summary inherit
Independent Staging Quality Gate / validate (push) Canceled after 3m8s
Independent Staging Quality Gate / publish (push) Canceled after 0s

BUG-729: dropped history rounds leave an omission marker in the model-visible summary slot.
BUG-730: checkpoint threshold is 0.4 of historyBudgetChars (128k still 16,000).
BUG-731: session_full new chat copies owned context_summary on the server; clients send only continued_from_session_id.
This commit is contained in:
jesse-ux
2026-09-16 07:38:36 +08:00
parent e61535f464
commit 149e1ec4c3
18 changed files with 451 additions and 31 deletions
+28 -7
View File
@@ -1,6 +1,12 @@
import { NextResponse } from "next/server";
import { chatSessionCreateSchema, ChatSessionBodyTooLargeError, readChatSessionJson } from "@/lib/chat-session-write-contract";
import {
chatSessionCreateInsertRow,
chatSessionCreateSchema,
ChatSessionBodyTooLargeError,
readChatSessionJson,
} from "@/lib/chat-session-write-contract";
import { consumeUserRequestRateLimit } from "@/lib/request-rate-limit";
import { resolveInheritedContextSummary } from "@/lib/session-context-summary";
import { isSupabaseConfigurationError } from "@/lib/supabase/config";
import { createServerSupabaseClient } from "@/lib/supabase/server";
import {
@@ -94,13 +100,28 @@ export async function POST(request: Request) {
}
const parsed = chatSessionCreateSchema.safeParse(await readChatSessionJson(request));
if (!parsed.success) return NextResponse.json({ error: "聊天记录格式不正确" }, { status: 400 });
const { id, updated_at: _ignoredClientClock, ...values } = parsed.data;
const { error } = await supabase.from("chat_sessions").insert({
id,
user_id: user.id,
...values,
updated_at: new Date().toISOString(),
const { id, updated_at: _ignoredClientClock, continued_from_session_id: continuedFromSessionId, ...values } = parsed.data;
const inheritedSummary = await resolveInheritedContextSummary({
continuedFromSessionId,
loadOwnedSummary: async (sourceId) => {
const { data } = await supabase
.from("chat_sessions")
.select("context_summary")
.eq("id", sourceId)
.eq("user_id", user.id)
.maybeSingle();
return data?.context_summary ?? null;
},
});
const { error } = await supabase.from("chat_sessions").insert(
chatSessionCreateInsertRow({
id,
userId: user.id,
values,
inheritedSummary,
updatedAt: new Date().toISOString(),
}),
);
if (error) return NextResponse.json({ error: "聊天记录暂时无法同步" }, { status: 500 });
return NextResponse.json({ ok: true }, { status: 201 });
} catch (error) {