PromptBusPromptBus

Task Types

PromptBus classifies every incoming request into one of seven task types. This classification drives the routing decision — determining which model and effort level to use.


Classification Method

The classifier uses keyword heuristics — no LLM call on the hot path. It analyzes the last user message in the conversation and extracts signals including:

  • Prompt length (in tokens)
  • Number of files in context
  • Number of tool calls so far in the turn
  • Keyword matches
  • Follow-up detection in long sessions
  • Whether the prior turn used extended thinking

Each signal contributes to a confidence score (0.0–1.0), which is compared against the configurable confidence_floor_for_any_downgrade threshold (default: 0.6).


Task Types Reference

read_explain

Brief read-only questions, code explanations, or documentation lookups. These are the most common candidates for downgrading to a cheaper model.

Signals

  • prompt_length_tokens: low
  • num_files_in_context: low
  • contains_keywords: 'what does', 'explain', 'how does', 'why is'
  • num_tool_calls_so_far_in_turn: 0

Default Action

Route to Haiku, low effort

Example Prompt

text
What does this function do?
```
function calculateTotal(items) {
  return items.reduce((sum, i) => sum + i.price, 0);
}
```

small_edit

Targeted edits with short prompts. Typically single-file changes with clear instructions.

Signals

  • prompt_length_tokens: medium
  • num_files_in_context: low
  • contains_keywords: 'add', 'change', 'update', 'remove', 'fix'
  • is_followup_in_long_session: false

Default Action

Route to Sonnet, medium effort

Example Prompt

text
Add input validation to the createUser function. Check that email is not empty and password is at least 8 characters.

multi_file_refactor

Cross-file refactoring or significant architectural changes spanning multiple files.

Signals

  • prompt_length_tokens: high
  • num_files_in_context: high (3+)
  • contains_keywords: 'refactor', 'restructure', 'migrate', 'extract'
  • prior_turn_used_extended_thinking: true

Default Action

Never downgrade

Example Prompt

text
Extract the authentication logic from server.ts into a separate auth service module. Update all imports across the project.

planning

Design, architecture planning, or implementation strategy discussions.

Signals

  • num_files_in_context: 0 (no files)
  • contains_keywords: 'plan', 'design', 'architecture', 'strategy', 'approach'
  • prompt_length_tokens: varies

Default Action

Never downgrade

Example Prompt

text
Design a database schema for a multi-tenant SaaS application with users, organizations, projects, and billing.

debug_loop

Debugging sessions, error fixing, or troubleshooting. These often involve iteration and extended thinking.

Signals

  • num_tool_calls_so_far_in_turn: high
  • is_followup_in_long_session: true
  • contains_keywords: 'error', 'bug', 'crash', 'debug', 'not working', 'issue'
  • prior_turn_used_extended_thinking: true

Default Action

Never downgrade

Example Prompt

text
I'm getting a 'TypeError: Cannot read properties of undefined' when I try to access the user profile page. Here's the stack trace and the component code.

test_generation

Writing unit tests, integration tests, or test suites.

Signals

  • contains_keywords: 'test', 'spec', 'unit test', 'integration test', 'coverage'
  • prompt_length_tokens: medium
  • num_files_in_context: low to medium

Default Action

Route to Sonnet, medium effort

Example Prompt

text
Write unit tests for the authentication middleware. Cover cases: valid token, expired token, missing token, and invalid signature.

unknown

Requests that don't clearly match any other task type. These default to safe (no downgrade) behavior.

Signals

  • No strong keyword matches
  • Confidence below threshold
  • Edge case or unusual request format

Default Action

Never downgrade (fail safe)

Example Prompt

text
(Various — any request that doesn't clearly fit the above categories)

Override Behavior

The classification and routing can be overridden in several ways:

  • Edit rules.yaml — Change which model each task type routes to, or mark it as never_downgrade
  • Adjust confidence floor — Lower or raise the threshold that determines whether downgrading is allowed
  • Disable routing — Set enabled: false in the config to pass all requests through unchanged