Skip to content

LoopObserver omits on_compaction and on_loop_cancelled, which BaseObserver defines and the loop dispatches #6

Description

@zhanghanduo

The two observer surfaces disagree. LoopObserver (Protocol, agent_core/loop_types.py:293) stops at on_loop_end; BaseObserver (:326) additionally defines on_compaction (:363) and on_loop_cancelled (:370) — and the loop dispatches both.

Consequences:

  • LoopObserver is @runtime_checkable, so isinstance(obs, LoopObserver) passes for an observer with no compaction hook. notify_observers' getattr(obs, method, None) probe then silently drops every compaction record for it — no warning, no log.
  • A strict-typed host holding list[LoopObserver] cannot call on_compaction at all, even though the CompactionEvent record and the COMPACTION_SEQ_KEY contract in agent_core/runtime/loop/compact.py are shared and expect a consumer.

Decision needed: if the two hooks are optional, say so in the Protocol docstring so the silent-drop behaviour is intended and documented. If they are contract, declare them on LoopObserver — which makes BaseObserver a conforming default rather than a superset. Related: #4 (the cancellation hook's drain gap).

Provenance: pre-existing in ApodexHarness/miroharness/core/loop_types.py, ported verbatim by #1 — not introduced by the refactor. ApodexHarness carries the same code and needs the same change until it consumes AgentCore.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions