Expand description
agents logs token-usage subscribe — wait for an agent’s stored
total_tokens snapshot to change, OR for its instance lock to
drop. One-shot: emits exactly one item then ends.
Flow:
- Read the current stored value (
baseline). - Fast path: if
--previousis set AND a value is stored AND it differs fromprevious, return that value immediately. - Otherwise subscribe: race the token-usage change (postgres
LISTEN, filtered + value-compared against
baseline) against the instance-lock release. On change →Item; on lock drop → a final change check, else"agents_inactive".