Skip to main content

Module subscribe

Module subscribe 

Source
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:

  1. Read the current stored value (baseline).
  2. Fast path: if --previous is set AND a value is stored AND it differs from previous, return that value immediately.
  3. 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".

Modules§

request_schema
response_schema

Functions§

execute