Skip to content

fix(core): enforce maxSteps limit exactly - #664

Open
cosin2077 wants to merge 2 commits into
alibaba:mainfrom
cosin2077:agent/fix-maxsteps
Open

fix(core): enforce maxSteps limit exactly#664
cosin2077 wants to merge 2 commits into
alibaba:mainfrom
cosin2077:agent/fix-maxsteps

Conversation

@cosin2077

@cosin2077 cosin2077 commented Aug 10, 2026

Copy link
Copy Markdown

What

Fix an off-by-one error in PageAgentCore.execute() that allows one extra agent step beyond maxSteps.

maxSteps is documented as the maximum number of steps a task may take, but the loop currently increments step and only stops when step > maxSteps. As a result, maxSteps: 1 can execute two LLM/tool steps, and the default maxSteps: 40 can execute 41.

This changes the boundary check to stop when step >= maxSteps and adds a regression test that verifies maxSteps: 1 performs exactly one LLM invocation before returning the step-limit error.

Type

  • Bug fix
  • Feature / Improvement
  • Refactor / Chores
  • Documentation / Website / Demo / Testing
  • Breaking change

Testing

  • npm test -w @page-agent/core
  • npm run typecheck
  • npm run lint

The patch was reviewed against current main (632424b).

Requirements / 要求

  • I have read and follow the Code of Conduct and Contributing Guide.
  • I have personally reviewed and meaningfully authored/reviewed every change before submission.

@cosin2077
cosin2077 marked this pull request as ready for review August 10, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant