Skip to content

Expired tool witness rings accumulate indefinitely on record-only routing paths #6083

Closed

Description

@Afloat16

Problem

The tool witness ring expires records only for the session being written, or globally during lookupToolWitness. Native-id routing can bypass hash lookup while every completed tool call is still recorded. Finished sessions' rings and reverse-index memberships therefore remain in memory indefinitely as new sessions arrive.

Reproduction

At master 541cf26, record one witness in each new session, advance a fake clock by the 10-minute TTL plus one millisecond between sessions, and never call lookupToolWitness. _toolRingSizeForTest grows from 1 to 2 and keeps growing, despite all earlier sessions being expired. A mixed fixture also shows a dead session retained alongside a fresh session sharing the same hash.

The existing tests/tool-ring.test.ts plus two regressions produces 24 passed / 2 failed on the base.

Expected

Record-only traffic must periodically reclaim expired sessions and their hash memberships. Fresh witnesses, duplicate-hash membership, the exact TTL lookup boundary, native-id precedence and collision refusal must remain intact. The full scan should be amortized, not repeated on every tool call.

Prior work

All 3,221 upstream PRs were screened. #1692 covers per-ring capacity, duplicate hashes and lookup-time TTL. #4978 adds native tool-use-id routing. Neither reclaims abandoned hash rings during record-only traffic. Previous Afloat16 PRs #6046–#6055 are excluded.

Category N; proposed labels p1 (unbounded cache residency), scope/other.

Activity

  1. ranxianglei commented on Nov 12, 2026

    @ranxianglei
    Owner

    Fixed in batch PR #6439 (merged).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions