Skip to content

fix: clear heartbeat session to prevent token overflow#2398

Merged
chengyongru merged 1 commit intoHKUDS:nightlyfrom
flobo3:fix/heartbeat-token-overflow-clean
Mar 23, 2026
Merged

fix: clear heartbeat session to prevent token overflow#2398
chengyongru merged 1 commit intoHKUDS:nightlyfrom
flobo3:fix/heartbeat-token-overflow-clean

Conversation

@flobo3
Copy link
Copy Markdown
Contributor

@flobo3 flobo3 commented Mar 23, 2026

Fixes #2375

This PR addresses the issue where the heartbeat session accumulates tasks over time, leading to massive token consumption (up to 560k tokens) and eventual context overflow.

Since the heartbeat is a stateless background task that doesn't need to remember its past executions, this PR simply clears the heartbeat session immediately after process_direct completes. This ensures the session remains clean and token usage stays minimal.

This approach is similar to how ironclaw handles routine notifications (nearai/ironclaw#1524), by preventing background tasks from polluting the long-term context.

@chengyongru chengyongru merged commit 41843b0 into HKUDS:nightly Mar 23, 2026
3 checks passed
@flobo3 flobo3 deleted the fix/heartbeat-token-overflow-clean branch March 23, 2026 15:18
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.

2 participants