Skip to content

Commit 63a4fc4

Browse files
committed
fix: add debug logging for model routing and make matching case-insensitive
1 parent 02cf395 commit 63a4fc4

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blockrun/clawrouter",
3-
"version": "0.3.24",
3+
"version": "0.3.25",
44
"description": "Smart LLM router — save 78% on inference costs. 30+ models, one wallet, x402 micropayments.",
55
"type": "module",
66
"main": "dist/index.js",

src/proxy.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,14 @@ async function proxyRequest(
316316
bodyModified = true;
317317
}
318318

319-
if (parsed.model === AUTO_MODEL || parsed.model === AUTO_MODEL_SHORT) {
319+
// Normalize model name for comparison (trim whitespace, lowercase)
320+
const normalizedModel = typeof parsed.model === "string" ? parsed.model.trim().toLowerCase() : "";
321+
const isAutoModel = normalizedModel === AUTO_MODEL.toLowerCase() || normalizedModel === AUTO_MODEL_SHORT.toLowerCase();
322+
323+
// Debug: log received model name
324+
console.log(`[ClawRouter] Received model: "${parsed.model}" -> normalized: "${normalizedModel}", isAuto: ${isAutoModel}`);
325+
326+
if (isAutoModel) {
320327
// Extract prompt from messages
321328
type ChatMessage = { role: string; content: string };
322329
const messages = parsed.messages as ChatMessage[] | undefined;
@@ -347,8 +354,11 @@ async function proxyRequest(
347354
if (bodyModified) {
348355
body = Buffer.from(JSON.stringify(parsed));
349356
}
350-
} catch {
351-
// JSON parse error — forward body as-is
357+
} catch (err) {
358+
// Log routing errors so they're not silently swallowed
359+
const errorMsg = err instanceof Error ? err.message : String(err);
360+
console.error(`[ClawRouter] Routing error: ${errorMsg}`);
361+
options.onError?.(new Error(`Routing failed: ${errorMsg}`));
352362
}
353363
}
354364

0 commit comments

Comments
 (0)