Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix: address Kilo Code review feedback on PR #2951
soyelmismo6cdf69e07701
diff --git a/open-sse/handlers/chatCore.ts b/open-sse/handlers/chatCore.tsindex b1eabdb92e..34c5aaf1b0 100644--- a/open-sse/handlers/chatCore.ts+++ b/open-sse/handlers/chatCore.ts@@ -277,10 +277,11 @@ function cloneBoundedChatLogPayload(value: unknown, depth = 0): unknown {return result;}-/** Fast size estimator — walks object tree without JSON.stringify */+/** Fast size estimator — walks object tree without JSON.stringify, with circular-ref protection */function estimateSizeFast(value: unknown): number {let bytes = 0;const stack: unknown[] = [value];+ const seen = new WeakSet();while (stack.length > 0) {const v = stack.pop();if (v === null || v === undefined) continue;@@ -290,6 +291,8 @@ function estimateSizeFast(value: unknown): number {} else if (typeof v === "number") bytes += 8;else if (typeof v === "boolean") bytes += 4;else if (typeof v === "object") {+ if (seen.has(v as object)) continue;+ seen.add(v as object);if (Array.isArray(v)) {for (let i = 0; i < v.length; i++) stack.push(v[i]);} else {@@ -1544,7 +1547,14 @@ export async function handleChatCore({const trace = (label: string, extra?: Record<string, unknown>) => {if (!traceEnabled) return;const elapsed = Date.now() - startTime;- const suffix = extra ? ` ${JSON.stringify(extra)}` : "";+ let suffix = "";+ if (extra) {+ try {+ suffix = ` ${JSON.stringify(extra)}`;+ } catch {+ suffix = " [unserializable]";+ }+ }log?.info?.("STAGE_TRACE", `${traceId} ${label} t=${elapsed}ms${suffix}`);};let tokensCompressed: number | null = null;