Skip to content

fix: classify current prompt intent, not full history#10

Merged
evansantos merged 1 commit intomainfrom
fix/classify-current-prompt
Feb 19, 2026
Merged

fix: classify current prompt intent, not full history#10
evansantos merged 1 commit intomainfrom
fix/classify-current-prompt

Conversation

@evansantos
Copy link
Copy Markdown
Owner

@evansantos evansantos commented Feb 19, 2026

Problem

The routing classifier was passing the entire conversation history (235+ messages, 300k+ chars) to classifyWithRouter. This caused every single request — even a simple "oi" — to be classified as reasoning tier with lengthy-content signal.

Fix

Changed the classification input to only include:

  • System prompt (for persona/context awareness)
  • Last 3 messages (conversational flow)
  • Current prompt (the actual request to classify)

This ensures the classifier evaluates the intent of the current request, not the volume of prior conversation.

Before

User: "oi"
🔀 Routing: reasoning tier (0.89) → opus | signals: [lengthy-content]

After

User: "oi"  
🔀 Routing: simple tier → haiku

User: "design a distributed cache"
🔀 Routing: complex tier → opus

Files Changed

  • src/index.tsllm_input hook routing classification

Fixes #9


🐕 GitSniff Summary

What this PR does

This pull request refines the routing classification logic within the slimclaw plugin by reducing the input context provided to the classifyWithRouter function. It now intelligently filters the conversation history, including only the system prompt, the last three messages, and the current prompt, to accurately assess the intent of the current request rather than the cumulative volume of the entire conversation. This change significantly improves the precision of AI model routing, preventing simple requests from being misclassified as complex, leading to more efficient resource utilization.

Key Changes

  • Modified the llm_input hook to pass a curated set of messages (system prompt, last 3 messages, current prompt) to classifyWithRouter.
  • Ensured that the classifier evaluates the intent of the current request rather than the entire conversation history.
  • Corrected the routing behavior, allowing simple prompts to be classified as 'simple tier' and complex prompts as 'complex tier'.
  • Addressed issue Routing classifier should evaluate current prompt, not full history #9 by preventing over-classification of prompts due to lengthy input.

Review Score: Excellent 🟢

Tip

No major issues found. Safe to merge.

Open in Dashboard

🐕 Reviewed by GitSniff

Route classification now uses only system prompt + last 3 messages +
current prompt instead of the entire conversation history (235+ msgs).

This prevents every request from being classified as 'reasoning' with
'lengthy-content' signal regardless of actual complexity.

Fixes #9
Copy link
Copy Markdown

@gitsniff gitsniff bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Score: Excellent

The PR addresses a critical issue where the routing classifier was over-classifying prompts due to excessive context. The fix involves adjusting the classifyWithRouter input to be more focused, incorporating only the system prompt, the last three messages, and the current prompt. This ensures accurate and contextually relevant routing decisions, improving the efficiency and correctness of the slimclaw plugin.

1 finding posted as inline comments below.

Review completed in 27s | Basic Plan | Gemini 2.5 Flash

const history = (historyMessages as any[]) || [];
const recentHistory = history.slice(-3);
for (const msg of recentHistory) {
if (!msg) continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Info

The history.slice(-3) operation will always return an array, even if empty. If history is undefined or null, recentHistory will be an empty array, and the loop will not execute. Therefore, the if (!msg) continue; check at src/index.ts:352 is redundant and can be removed.

Fix: Remove the if (!msg) continue; statement as msg will always be defined within the loop if recentHistory contains elements. The recentHistory array will not contain null or undefined elements itself.

🤖 Prompt for AI Agents
In src/index.ts around line 352:

Issue: The `history.slice(-3)` operation will always return an array, even if empty. If `history` is `undefined` or `null`, `recentHistory` will be an empty array, and the loop will not execute. Therefore, the `if (!msg) continue;` check at `src/index.ts:352` is redundant and can be removed.

Remove the `if (!msg) continue;` statement as `msg` will always be defined within the loop if `recentHistory` contains elements. The `recentHistory` array will not contain `null` or `undefined` elements itself.


@evansantos evansantos merged commit 6270df8 into main Feb 19, 2026
6 checks passed
evansantos added a commit that referenced this pull request Feb 19, 2026
- Replace `as any` routing config access with typed Record<string, unknown>
- Type routingTier as ComplexityTier instead of string (remove `as any`)
- Handle content blocks properly: extract text from arrays instead of JSON.stringify
- Remove redundant null guard in classification message loop

Closes #12
evansantos added a commit that referenced this pull request Feb 19, 2026
- Replace `as any` routing config access with typed Record<string, unknown>
- Type routingTier as ComplexityTier instead of string (remove `as any`)
- Handle content blocks properly: extract text from arrays instead of JSON.stringify
- Remove redundant null guard in classification message loop

Closes #12
@evansantos evansantos deleted the fix/classify-current-prompt branch February 19, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Routing classifier should evaluate current prompt, not full history

1 participant