Skip to content

fix(engine): wire compaction_callback through auto-selection path in AgentEngine #577

@Aureliolo

Description

@Aureliolo

Problem

AgentEngine._resolve_loop() calls build_execution_loop() without passing compaction_callback. This means loops created via the auto-selection path (auto_loop_config) never get compaction wired in.

The static path (_make_default_loop()) does wire compaction correctly, but the dynamic auto-selection path does not.

Affected code

src/synthorg/engine/agent_engine.py lines ~1062-1066:

return build_execution_loop(
    loop_type,
    approval_gate=self._approval_gate,
    stagnation_detector=self._stagnation_detector,
    # Missing: compaction_callback=...
)

Impact

Any agent using auto_loop_config (which routes COMPLEX/EPIC tasks to hybrid, MEDIUM to plan_execute) will run without context compaction, even if compaction is configured elsewhere. This could lead to context window exhaustion on long-running tasks -- exactly the tasks that auto-selection is designed for.

Fix

Wire compaction_callback through _resolve_loop() the same way approval_gate and stagnation_detector are wired. This requires:

  1. Adding a compaction_callback attribute to AgentEngine (or building it from config)
  2. Passing it to build_execution_loop() in _resolve_loop()

Discovered during #199 (Hybrid execution loop implementation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:mediumShould do, but not blockingscope:smallLess than 1 day of workspec:agent-systemDESIGN_SPEC Section 3 - Agent Systemspec:memoryDESIGN_SPEC Section 7 - Memory & Persistencetype:fixBug fixes and corrections

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions