Skip to content

Smart File Routing

When your project has many files, Whittl doesn't send all of them to the AI every time. It parses your imports, analyzes your prompt, and sends only the files that are actually relevant to the current request. The status bar shows "3 of 27 files sent" when routing activates.

Why this exists

Without routing, a 30-file project with 8,000 lines total would send all 8,000 lines on every turn. That wastes tokens (= money), slows the response, and distracts the AI from the files that matter for this specific change.

With routing, the same project might send 3 files and 600 lines for a change to the settings dialog. Cheaper, faster, more focused.

How it decides what to send

Three signals combined:

  1. Import graph — If you're editing dialogs/settings.py and it imports from utils/config.py, utils/config.py comes along. Transitive imports up to 2 hops deep.
  2. Keyword matching — If your prompt says "add a retry button to the download dialog" and a file is named download_dialog.py, it's included regardless of what was open.
  3. Active file — Whatever's focused in the editor is always included.

Plus a fallback: if the project is small (≤5 files), everything goes. If routing would exclude the current editor focus, the focus file is always added back.

When it fires

  • Project has more than 5 files by default
  • Smart Routing for All Projects toggle (Preferences → Generation) lowers the threshold if you want aggressive routing on small projects too

What you see in the chat

When routing selects a subset, the status bar shows:

Sent: main.py, dialogs/settings.py, utils/config.py (3 of 27 files)

Real-time indicator — you know exactly what context the AI had for this specific response.

Escape hatches

If routing misses a file you need:

  • Send Active File Only (Preferences) — forces only the focused tab, overrides routing
  • Mention the file explicitly in your prompt — "in helpers/auth.py, add a token refresh" pulls it in via keyword matching
  • Open the file in the editor — active files are always included

What it doesn't do

  • Routing operates on files, not on snippets within files. A 2,000-line file that's selected-in sends the full file.
  • Routing doesn't decide the AI's edits — it only decides what context the AI sees. The AI still edits whatever it thinks it needs to.
  • Routing respects assets/ and data/ exclusions by default (user data is not sent as context).

Cost impact

Field numbers from a typical multi-file project session:

  • Without routing: ~50k input tokens per turn → ~$0.15 on Sonnet, ~$0.01 on DeepSeek
  • With routing: ~8k input tokens per turn → ~$0.02 on Sonnet, ~$0.002 on DeepSeek

Smart routing is on by default for a reason.

Interaction with other features

  • Prompt Caching — cached context survives across turns, so routing's smaller context caches well
  • Agent Mode — routing runs on each round, so Agent Mode doesn't re-send the whole project 20 times
  • Auto-fix — fix rounds reuse the routed context from the initial generation when possible

All three compound: routing cuts input size, caching discounts it further, and autofix avoids round-trips entirely where a static rule handles the fix.

What's next