Skip to content

[Bug]: MemoryProvider.on_turn_start() hook is never called — breaks Honcho cadence logic and plugin turn tracking #7193

@Tranquil-Flow

Description

@Tranquil-Flow

Bug Description

The MemoryProvider ABC defines on_turn_start(turn_number, message, **kwargs) (agent/memory_provider.py line 144) and memory_manager.py has a complete dispatch method that iterates providers and calls it (lines 265-277). However, run_agent.py never calls memory_manager.on_turn_start() anywhere.

This means _turn_count stays at 0 in every memory plugin that relies on it.

Steps to Reproduce

  1. Enable Honcho with dialectic_cadence or injection_frequency set to any value > 1
  2. Have a multi-turn conversation (5+ turns)
  3. Observe via DEBUG logging that Honcho's on_turn_start() is never called
  4. Observe that _turn_count remains 0 throughout the session

Quick verification:

grep -n "on_turn_start" run_agent.py
# Returns no results — the call is missing entirely

Expected Behavior

memory_manager.on_turn_start() should be called once per user turn, after the turn counter is incremented, so that memory plugins can track turn progression and gate behavior (e.g., Honcho's cadence logic, Supermemory's turn tracking).

Actual Behavior

The hook is never invoked. All plugins that implement on_turn_start() have their turn-tracking fields stuck at their initial value (0).

Affected plugins:

  • Honcho (plugins/memory/honcho/__init__.py lines 516-518): Sets self._turn_count = turn_number. Used in queue_prefetch() (lines 485-490) for dialectic_cadence and injection_frequency checks — both broken.
  • Supermemory (plugins/memory/supermemory/__init__.py lines 527-528): Sets self._turn_count = max(turn_number, 0) — never called.

Affected Component

Agent Core (conversation loop, context compression, memory)

Messaging Platform (if gateway-related)

N/A (CLI only)

Operating System

macOS 15.6.1

Python Version

3.11.14

Hermes Version

v0.8.0

Root Cause Analysis (optional)

The hook was defined in the ABC and dispatch was implemented in memory_manager.py, but the call was never wired into the main agent loop in run_agent.py. The natural insertion point is after self._user_turn_count += 1 (line 7156), where the agent already tracks turn progression.

The infrastructure is complete — the only missing piece is the single call from run_agent.py.

Proposed Fix (optional)

Add the call in run_agent.py after line 7156 (self._user_turn_count += 1):

if self._memory_manager:
    try:
        self._memory_manager.on_turn_start(
            self._user_turn_count,
            user_message if isinstance(user_message, str) else str(user_message),
            platform=getattr(self, '_platform', None),
            model=self._current_model if hasattr(self, '_current_model') else self.model,
            tool_count=len(self.valid_tool_names) if hasattr(self, 'valid_tool_names') else 0,
        )
    except Exception:
        pass

PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent loop, run_agent.py, prompt buildercomp/pluginsPlugin system and bundled pluginstool/memoryMemory tool and memory providerstype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions