Unbounded Memory Usage in AutoDebugAgent due to MemorySaver #9116

Open
opened 2026-04-14 07:49:23 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(agents): replace MemorySaver with BoundedMemorySaver in AutoDebugAgent
  • Branch: fix/auto-debug-agent-bounded-memory-saver

Background and Context

An issue of unbounded memory usage has been identified in the AutoDebugAgent in src/cleveragents/agents/graphs/auto_debug.py.

The AutoDebugAgent uses langgraph.checkpoint.memory.MemorySaver for checkpointing the state of its LangGraph workflow. This saver stores all checkpoints in memory without any limit. In long-running debugging sessions with many retries, this leads to a continuous increase in memory consumption, which can eventually cause the application to crash or degrade performance significantly.

Code Evidence:

  • cleveragents.agents.graphs.auto_debug.AutoDebugAgent.__init__ (commit 67e084c7876e4d25889069784d373d56002572a1): self.checkpointer = MemorySaver()

This is inconsistent with PlanGenerationGraph in src/cleveragents/agents/graphs/plan_generation.py, which already uses a BoundedMemorySaver class to limit the number of checkpoints stored in memory.

Expected Behavior

The AutoDebugAgent should use a bounded checkpointer that limits the number of in-memory checkpoints, preventing unbounded memory growth during long-running or high-retry debugging sessions.

Acceptance Criteria

  • AutoDebugAgent.__init__ uses BoundedMemorySaver (or equivalent bounded checkpointer) instead of MemorySaver
  • The maximum number of checkpoints is configurable or set to a sensible default (e.g., max_checkpoints=5)
  • Memory usage does not grow unboundedly when the agent is run in a loop with many retries
  • All existing tests for AutoDebugAgent continue to pass
  • New BDD test scenario added to verify that the checkpointer is bounded

Subtasks

  • Import BoundedMemorySaver from cleveragents.agents.graphs.plan_generation (or refactor it to a shared location)
  • Replace self.checkpointer = MemorySaver() with self.checkpointer = BoundedMemorySaver(max_checkpoints=5) in AutoDebugAgent.__init__
  • Add or update docstring to document the bounded checkpointing behavior
  • Tests (Behave): Add scenario verifying AutoDebugAgent uses a bounded checkpointer
  • Verify coverage ≥97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (fix(agents): replace MemorySaver with BoundedMemorySaver in AutoDebugAgent), followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (fix/auto-debug-agent-bounded-memory-saver).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `fix(agents): replace MemorySaver with BoundedMemorySaver in AutoDebugAgent` - **Branch**: `fix/auto-debug-agent-bounded-memory-saver` ## Background and Context An issue of unbounded memory usage has been identified in the `AutoDebugAgent` in `src/cleveragents/agents/graphs/auto_debug.py`. The `AutoDebugAgent` uses `langgraph.checkpoint.memory.MemorySaver` for checkpointing the state of its LangGraph workflow. This saver stores all checkpoints in memory without any limit. In long-running debugging sessions with many retries, this leads to a continuous increase in memory consumption, which can eventually cause the application to crash or degrade performance significantly. **Code Evidence:** - `cleveragents.agents.graphs.auto_debug.AutoDebugAgent.__init__` (commit `67e084c7876e4d25889069784d373d56002572a1`): `self.checkpointer = MemorySaver()` This is inconsistent with `PlanGenerationGraph` in `src/cleveragents/agents/graphs/plan_generation.py`, which already uses a `BoundedMemorySaver` class to limit the number of checkpoints stored in memory. ## Expected Behavior The `AutoDebugAgent` should use a bounded checkpointer that limits the number of in-memory checkpoints, preventing unbounded memory growth during long-running or high-retry debugging sessions. ## Acceptance Criteria - [ ] `AutoDebugAgent.__init__` uses `BoundedMemorySaver` (or equivalent bounded checkpointer) instead of `MemorySaver` - [ ] The maximum number of checkpoints is configurable or set to a sensible default (e.g., `max_checkpoints=5`) - [ ] Memory usage does not grow unboundedly when the agent is run in a loop with many retries - [ ] All existing tests for `AutoDebugAgent` continue to pass - [ ] New BDD test scenario added to verify that the checkpointer is bounded ## Subtasks - [ ] Import `BoundedMemorySaver` from `cleveragents.agents.graphs.plan_generation` (or refactor it to a shared location) - [ ] Replace `self.checkpointer = MemorySaver()` with `self.checkpointer = BoundedMemorySaver(max_checkpoints=5)` in `AutoDebugAgent.__init__` - [ ] Add or update docstring to document the bounded checkpointing behavior - [ ] Tests (Behave): Add scenario verifying `AutoDebugAgent` uses a bounded checkpointer - [ ] Verify coverage ≥97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`fix(agents): replace MemorySaver with BoundedMemorySaver in AutoDebugAgent`), followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`fix/auto-debug-agent-bounded-memory-saver`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-14 08:08:24 +00:00
Author
Owner

Triage: Verified [AUTO-OWNR-1]

Valid bug: AutoDebugAgent has unbounded memory usage due to MemorySaver accumulating all conversation history without bounds. This is a resource leak that will cause OOM failures in long-running sessions.

Assigning to v3.5.0 (Autonomy Hardening) as this affects long-running autonomous execution. Priority High — unbounded memory growth will cause failures in production.

MoSCoW: Must Have — memory bounds are essential for reliable autonomous operation.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Triage: Verified** [AUTO-OWNR-1] Valid bug: `AutoDebugAgent` has unbounded memory usage due to `MemorySaver` accumulating all conversation history without bounds. This is a resource leak that will cause OOM failures in long-running sessions. Assigning to **v3.5.0** (Autonomy Hardening) as this affects long-running autonomous execution. Priority **High** — unbounded memory growth will cause failures in production. MoSCoW: **Must Have** — memory bounds are essential for reliable autonomous operation. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#9116
No description provided.