LemonRouter. StickyEngine
(lemon_router v0.1.0)
View Source
Extracts engine preference from user prompts.
Detects patterns like "use codex", "switch to claude", "with gemini" at the start of a message and returns the engine ID if it matches a known engine.
Summary
Functions
Attempt to extract an engine preference from the beginning of a prompt.
Apply sticky engine logic for a run.
Functions
Attempt to extract an engine preference from the beginning of a prompt.
Returns {:ok, engine_id} if a known engine switch pattern is found,
or :none if no engine preference is detected.
Patterns matched
- "use <engine>"
- "switch to <engine>"
- "with <engine>"
These are matched case-insensitively and only at the start of the prompt (with optional leading whitespace).
Apply sticky engine logic for a run.
Given the current session config, the run's explicit engine_id, and the prompt, determines the effective engine_id and any updates to the session policy.
Returns {effective_engine_id, session_updates} where:
effective_engine_idis the engine to use for this run (or nil for default)session_updatesis a map to merge into session policy (may contain:preferred_engine)