fix(#937): use has_pending_with_body in worker — mirrors broker change

This commit is contained in:
damocles 2026-06-01 14:43:12 +02:00 committed by mara
commit 3283362b36

View file

@ -97,16 +97,16 @@ fn fire_schedule(coord: &Arc<Coordinator>, schedule: &Schedule, now: i64) {
continue; continue;
} }
// Skip delivery if there is already an unread message from // Skip delivery if there is already an unread message from
// "scheduled" waiting in this target's inbox. Prevents prompt // "scheduled" waiting in this target's inbox. Prevents the same
// accumulation when the agent is slow to drain its queue or // scheduled prompt from stacking up when an agent is slow or
// was briefly offline: at most one scheduled message is ever // briefly offline, while still allowing distinct scheduled
// pending per target at a time. // messages (different body) to enqueue independently.
match coord.broker.has_pending_from(target, "scheduled") { match coord.broker.has_pending_with_body(target, "scheduled", &schedule.body) {
Ok(true) => { Ok(true) => {
tracing::debug!( tracing::debug!(
schedule = schedule.id, schedule = schedule.id,
%target, %target,
"scheduled_prompts: skipping — target already has pending scheduled message" "scheduled_prompts: skipping — same body already pending for target"
); );
let _ = coord.scheduled_prompts.record_target_result( let _ = coord.scheduled_prompts.record_target_result(
schedule.id, schedule.id,
@ -117,7 +117,7 @@ fn fire_schedule(coord: &Arc<Coordinator>, schedule: &Schedule, now: i64) {
continue; continue;
} }
Err(e) => { Err(e) => {
tracing::warn!(schedule = schedule.id, %target, error = ?e, "has_pending_from failed"); tracing::warn!(schedule = schedule.id, %target, error = ?e, "has_pending_with_body failed");
} }
Ok(false) => {} Ok(false) => {}
} }
@ -384,3 +384,4 @@ async fn known_agents_async() -> std::collections::HashSet<String> {
} }
out out
} }