Skip to main content

try_reserve_runner

Function try_reserve_runner 

Source
pub async fn try_reserve_runner(
    runners: &Arc<RwLock<HashMap<String, AgentRunner>>>,
    senders: &Arc<RwLock<HashMap<String, Sender<AgentEvent>>>>,
    session_id: &str,
    event_sender: &Sender<AgentEvent>,
) -> Option<RunnerReservation>
Expand description

Try to reserve a runner for the given session.

Returns None if a Running runner already exists (the caller skips execution and surfaces the existing run_id separately). Otherwise reserves a fresh runner AND re-asserts the session sender into senders — see reserve_runner_core.

The re-assert is required, not optional: this function is reached by the resume paths (/respond, child-completion coordinator, gold auto-answer via resume_session_execution), which re-execute a long-lived session under the SAME id after a wait that easily exceeds the idle TTL — exactly the evict-then-re-execute race #346’s sweep newly opens.