Skip to content

fix(xchat): keep inbound alive inside X's per-endpoint daily budgets (salvage #280 + #227) - #437

Closed
teknium1 wants to merge 4 commits into
mainfrom
salvage/228-xchat-poll-budget
Closed

teknium1 wants to merge 4 commits into
mainfrom
salvage/228-xchat-poll-budget

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Inbound X Chat stopped for the rest of the day once the account's conversation-list budget ran out (#228). Two causes:

  • The poll loop read GET /2/chat/conversations on every cycle. X meters that endpoint against its own 1,000 calls / 24 h allowance, so at the 10 s default the list budget is gone in under 3 hours.
  • A 429 from the list ended the whole cycle, even though the events endpoint (10,000 / 24 h) would still have answered.

This combines the earliest correct fix for each cause, with authorship kept:

No new env vars or config keys.

Supersedes #280 and #227. Not taken: #226 (adaptive pacing with a token bucket). It adds three new non-secret XCHAT_* env knobs and still spends one list read per cycle, so it doesn't fix the budget on its own.

Refs #228. The streaming transport proposed there is still a separate change, so the issue stays open for it.

Tests

xchat/tests: 67 passed, against a main baseline of 60. The 7 new tests fail over main's source. My 2 tests also fail over the cherry-picks alone.

Merged together with #191, #278 and #323: no conflicts, 72 passed.

kanederkson and others added 4 commits November 19, 2026 04:10
The poll loop spent one conversation-list read per cycle. The list endpoint is billed per call against a separate 1,000/day budget, so at the default 30 s interval the budget empties in about 8 hours and inbound dies for the rest of the window.

Discovery now runs at startup and then at most every max(600 s, 20 poll cycles); between discoveries every known conversation is polled directly (an idle events page returns no resources). New conversations are picked up on the next discovery pass instead of within one poll cycle - the trade the budget imposes.

Refs #228.
The plugin learns which conversations to read by listing them first, then
reading each conversation's events. Those two endpoints are metered separately:
the list carries the account's 1,000-call daily user budget, whilst the
per-conversation events endpoint runs on a much larger allowance (measured
headers: x-user-limit-24hour-limit 1000 on the list, 10000 on events).

A 429 from the list therefore ended the whole poll cycle and slept for up to
fifteen minutes, even though the events endpoint would have answered. Observed
on a live account: list 429 with x-user-limit-24hour-remaining: 0, events 200
with 9990 remaining — inbound was dead for the rest of the day with no error
beyond the rate-limit warning.

Conversation ids are now kept (~/.hermes/xchat/conversations.json, mode 600) and
recovered from the cursor state, so a throttled list degrades to polling known
conversations directly. Discovery is retried when the throttle is due to lift
rather than every cycle, which would spend a refused request each time.
os.chmod(0o600) does not change the mode Windows reports (666), so the
restart test failed before it reached the persistence check. The mode
check stays on POSIX.
…inned sets pinned

Salvage follow-up on #280 + #227. With discovery on its own cadence every known
conversation gets an events read each cycle, so a long-lived account with many
(persisted) conversations would trade the list budget for the events one
(10,000/24h): the cycle now stretches past XCHAT_POLL_INTERVAL once the reads
would exceed 9,000/day (one conversation at the 10 s default is unchanged).
Persisted conversation ids no longer widen an explicitly pinned
XCHAT_CONVERSATION_IDS set. README describes the new inbound cadence.
@teknium1

Copy link
Copy Markdown
Contributor Author

Landed on main via #446 (tip f99d3fd), stacked with the other reviewed official PRs so shared files conflicted only once. To get it now: hermes plugins install NousResearch/hermes-official-plugins#<plugin> --force; hermes plugins update follows once the catalog pin moves (in progress).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants