fix(agent99): rotate outcome reconciliation cohorts
This commit is contained in:
@@ -2215,14 +2215,37 @@ class PostgresAgent99DispatchLedger:
|
||||
]),
|
||||
)
|
||||
# Prioritize observed delivery/outcome lanes; pending crash
|
||||
# recovery candidates are polled after them.
|
||||
# recovery candidates are polled after them. Heartbeat is
|
||||
# also the durable poll cursor: each selected cohort is
|
||||
# touched below so unresolved old runs cannot starve newer
|
||||
# outcomes forever.
|
||||
.order_by(
|
||||
(AwoooPRunState.state == "pending").asc(),
|
||||
AwoooPRunState.heartbeat_at.asc().nullsfirst(),
|
||||
AwoooPRunState.created_at.asc(),
|
||||
)
|
||||
.limit(max(1, min(int(limit), 100)))
|
||||
)
|
||||
rows = result.all()
|
||||
if rows:
|
||||
await db.execute(
|
||||
update(AwoooPRunState)
|
||||
.where(
|
||||
AwoooPRunState.project_id
|
||||
== (project_id or "awoooi"),
|
||||
AwoooPRunState.agent_id
|
||||
== AGENT99_DISPATCH_AGENT_ID,
|
||||
AwoooPRunState.run_id.in_([
|
||||
row.run_id for row in rows
|
||||
]),
|
||||
AwoooPRunState.state.in_([
|
||||
"pending",
|
||||
"running",
|
||||
"waiting_tool",
|
||||
]),
|
||||
)
|
||||
.values(heartbeat_at=_utc_now_naive())
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"agent99_dispatch_reconciliation_list_failed",
|
||||
|
||||
Reference in New Issue
Block a user