Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.
Rust ai-agentsai-gatewayclaude-codecodexcoding-agentcost-optimizationdeepseekllm-gatewayllm-routerlocal-firstmodel-routingrusttask-routingtauri
use std::cell::Cell;
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Fault {
None,
LoseApplyResponseAndDisconnect,
LoseBeforeApply,
}
thread_local! { pub static FAULT: Cell<Fault> = const { Cell::new(Fault::None) }; }
pub fn take(fault: Fault) -> bool {
FAULT.with(|current| {
if current.get() == fault {
current.set(Fault::None);
true
} else {
false
}
})
}