Skip to content

[Bug]: BaseAgent iteration counter not resetting between turns requiring manual workaround. #36

Description

@deepakn97

Bug Description

When running BaseAgent with max_iterations=1 for single-step execution, the internal iterations counter persists across multiple agent_loop() calls. This causes the agent to stop executing after the first turn unless the counter is manually reset to 0 before each turn. Both UserAgent and ProactiveAgent currently use a hacky workaround (self.react_agent.iterations = 0) that violates proper encapsulation and doesn't conform to Meta-ARE standards.
BaseAgent can be reset by passing reset=True, however, this also erases all the logs and history for the agent which causes issues as well.

Steps to Reproduce

  1. Create a UserAgent with max_iterations=1 (pas/agents/user/agent.py:73)
  2. Call user_agent.agent_loop() for the first turn
  3. Agent executes successfully (iterations: 0 → 1)
  4. Call user_agent.agent_loop() for the second turn without manual reset
  5. Agent immediately exits because self.react_agent.iterations = 1 already equals max_iterations
  6. No tool calls execute on turn 2

Expected Behavior

When calling agent_loop() multiple times:

  1. Each call should execute exactly max_iterations steps (e.g., 1 step for UserAgent)
  2. The iterations counter should reset automatically between turns
  3. No manual manipulation of internal BaseAgent state should be required
  4. The reset parameter in BaseAgent.run() should handle counter resets properly

Actual Behavior

Without the manual workaround:
  1. Turn 1: Agent executes 1 step (iterations: 0 → 1) ✓
  2. Turn 2: Agent immediately exits (iterations already = 1) ✗
  3. Turn 3+: Agent never runs again ✗

Current workaround (pas/agents/user/agent.py:316-318):
  # Reset the internal iterations counter, otherwise after first turn, the agent will exit.
  # ! FIXME: Find a better solution for this iterations issue.
  self.react_agent.iterations = 0

  Same workaround in (pas/agents/proactive/agent.py:475-477):
  # ! FIXME: Find a better solution for this iterations issue.
  self.observe_agent.iterations = 0

Component

Agents

Environment

- OS: macOS 15.6
  - Python version: 3.13.2
  - PAS version/commit: v0.0.1 (commit 3bc3835)
  - Branch: main
  - Installed via: uv

Minimal Reproducible Example

Relevant Logs

Additional Context

No response

Pre-submission Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have included a minimal reproducible example (if applicable)
  • I have included relevant logs and error messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsAll files in `pas/agents/`bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions