Skip to content

[Phase 2.5] ReactAgent iteration budget too small for multi-file tasks #377

Description

@frankbria

Problem

With a 30-iteration budget, the ReactAgent cannot complete tasks that require creating multiple files. Each file creation + lint-fix cycle takes 3-5 iterations, and the agent spends ~9 iterations on exploration (see #373). This leaves budget for only 4-7 files.

Observed Behavior

Task "Design Data Model for Tasks" on cf-test:

The agent generated working, lint-clean code for 3 files but ran out of budget before completing the task.

Contributing Factors

  1. Exploration waste ([Phase 2.5] ReactAgent wastes 30% of iteration budget on redundant file exploration #373) — 9 iterations reading files the system prompt could include
  2. Lint fix overhead — each file requires 2-4 iterations to pass ruff (create → get errors → fix → verify)
  3. Fixed budget — 30 iterations regardless of task complexity
  4. No early termination — agent doesn't signal "I'm done" when the code is ready; it keeps iterating

Proposed Fixes

Several complementary approaches:

  1. Fix [Phase 2.5] ReactAgent wastes 30% of iteration budget on redundant file exploration #373 first — reducing exploration from 9 to 2-3 iterations immediately frees 6-7 iterations
  2. Adaptive iteration budget — scale budget based on task complexity (number of files expected, dependency count)
  3. Ruff auto-fix integration — run ruff check --fix automatically before the lint gate, reducing fix iterations from 3-5 to 1
  4. Agent completion signal — let the agent end early when it determines the task is done (stop_reason check)

Impact

After fixing #372 (gate resilience) and #373 (exploration waste), the effective iteration budget would be ~25 iterations for implementation. With ruff auto-fix, each file would take ~2 iterations. This would allow 10-12 files per task — sufficient for most tasks.

Files

  • codeframe/core/react_agent.py_react_loop() iteration limit, _build_system_prompt() for context pre-loading
  • codeframe/core/gates.py — potential ruff auto-fix integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphase-2Phase 2: Server Layer as Thin Adapter

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions