Skip to content

Removed BYOK keys remain active in the runtime pool until restart #26

Description

@robbyczgw-cla

What I was trying to do

Remove or rotate one configured BYOK API key with hound keys remove while keeping another key for the same provider, relying on the existing runtime config refresh rather than restarting Hound.

Unexpected behavior

_refresh_pools() adds newly configured keys, but it does not remove individual keys that disappeared from the current configuration while the provider still has at least one key.

For example, after changing a Serper configuration from ["keep-key", "removed-key"] to ["keep-key"], the in-memory pool still contains both entries and can continue rotating to removed-key until the server restarts.

Minimal reproduction

_POOLS["serper"] = KeyPool(["keep-key", "removed-key"])
# load_byok_keys() now returns only {"serper": ["keep-key"]}
_refresh_pools()

assert _POOLS["serper"]._keys == ["keep-key"]  # currently fails

Expected behavior

A refresh should reconcile pool membership and order with the current configuration, immediately remove deleted keys, preserve health/cooldown state for retained keys, and safely maintain rotation.

Environment

  • Hound: 12.3.0
  • Python: 3.12
  • Linux

Proposed fix

I prepared a focused PR that reconciles existing pools without discarding retained-key state. Regression tests cover partial removal, reordered keys, removal around the rotation cursor, state preservation, and removal of an empty provider pool. The new BYOK lifecycle is a useful addition; this just makes key removal as dynamic as key addition.

Activity

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