Expand description
Per-turn effort routing (#1148, opt-in dynamic thinking budget).
Unlike the static effort.rs which applies a constant reasoning level
across all turns (for cache stability), this module classifies each turn
and adjusts thinking effort dynamically.
Opt-in only (proxy.effort_routing = true). When disabled, the static
effort.rs path remains the sole controller. When enabled, this module
overrides the static level with a per-turn classification.
§Cache stability tradeoff
Provider prompt caches (Anthropic cache_control, OpenAI prefix caching)
break when reasoning parameters change. This module accepts that tradeoff
because:
- Output tokens on Opus-class models cost 5x input tokens — savings from reduced thinking often exceed the cache-miss penalty.
- Routine turns (file reads, passing tests) generate disproportionate thinking waste for trivial tool-result acknowledgements.
- The module uses a two-level strategy (not N levels) to minimize cache
key diversity:
routineorfull— only two cache prefixes to warm.
§Classification
A turn is classified as routine when the last assistant message was a tool call and the tool result indicates success on a non-complex operation:
- File read (tool_use with
ctx_read,read_file,Read) - Successful shell command (exit_code == 0, no error indicators)
- Search results (grep/glob/find)
- Status checks (git status, test passing)
A turn is classified as full (keep maximum thinking) when:
- The user sent a new message (requires understanding intent)
- The tool result contains errors/failures
- Multiple tool results arrived (complex multi-step)
- The content is architecturally complex (refactoring, debugging)
Structs§
- Routing
Stats - Statistics for monitoring effort routing effectiveness.
Enums§
- Turn
Class - Turn classification result.
Functions§
- classify_
turn - Classify the current turn based on the message array.
Returns
Routineif the latest context is a simple tool-result acknowledgement,Fullotherwise. - classify_
turn_ anthropic - Classify based on Anthropic messages structure.
- classify_
turn_ responses - Classify based on OpenAI Responses API
inputarray (different structure). - effort_
for_ turn - Map a turn classification to the effort level to apply.
baseis the operator’s configured static effort level. - intent_
aware_ effort - Adjust effort from a classifier intent while preserving the configured effort for intents that are not clearly simple reads or coding work.
- stats
- Snapshot routing statistics.