Awesome Reviewers

Reviewer · Logging

Warn-once dedup key granularity

When suppressing repeated warnings to avoid log flooding (e.g. a process-global "warn-once" set), choose a dedup key that is specific enough to still surface genuinely new problems, but not so specific that it floods logs on normal usage patterns. Key on stable, semantically meaningful identifiers such as `module.ClassName.attribute_name:failure_type`...

Instruction

When suppressing repeated warnings to avoid log flooding (e.g. a process-global “warn-once” set), choose a dedup key that is specific enough to still surface genuinely new problems, but not so specific that it floods logs on normal usage patterns. Key on stable, semantically meaningful identifiers such as module.ClassName.attribute_name:failure_type rather than on per-instance identity (id(self)), since instance ids are reused after garbage collection and short-lived objects (e.g. one Agent per request) would otherwise re-trigger the same warning on every creation. Critically, include the nature of the failure (e.g. the offending value’s type) in the key, not just the class and attribute: suppressing by class+attribute alone silently swallows subsequent warnings for a different, newly-introduced failure type on the same attribute, which hides real regressions in long-running processes.

Example:

name = f"{type(self).__module__}.{type(self).__qualname__}.{attr_name}"
type_name = type(attr_value).__name__
key = f"{name}:{type_name}"
if key not in _warned:
    _warned.add(key)
    logger.warning(f"{name} ({type_name}) is not serializable")

This keeps the suppression set bounded (it grows only with distinct class/attribute/type combinations that actually fail, not with the number of instances created) while ensuring that a new, different failure on an already-warned attribute is still logged. Avoid exposing or relying on ad-hoc access to the internal suppression state from outside the logging module; if tests need to reset it, keep that reset confined to the test(s) that require it rather than building a public API for a single caller.