Cap get_api_docs, break duplicate tool rounds, force a reply after successful writes, and log each tool call so limit hits are diagnosable.
This commit is contained in:
@@ -4,6 +4,7 @@ export type AssistantChatMessage = {
|
||||
role: "user" | "assistant";
|
||||
content: string;
|
||||
imageUrl?: string;
|
||||
toolCalls?: Array<{ name: string; status: number }>;
|
||||
};
|
||||
|
||||
const STORAGE_VERSION = "v2";
|
||||
@@ -19,6 +20,14 @@ function isValidMessage(value: unknown): value is AssistantChatMessage {
|
||||
if (row.role !== "user" && row.role !== "assistant") return false;
|
||||
if (typeof row.content !== "string" || row.content.trim().length === 0) return false;
|
||||
if (row.imageUrl !== undefined && typeof row.imageUrl !== "string") return false;
|
||||
if (row.toolCalls !== undefined) {
|
||||
if (!Array.isArray(row.toolCalls)) return false;
|
||||
for (const call of row.toolCalls) {
|
||||
if (!call || typeof call !== "object") return false;
|
||||
const entry = call as Record<string, unknown>;
|
||||
if (typeof entry.name !== "string" || typeof entry.status !== "number") return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user