Skip to content

feat(agent-service): lower the default step limit to 25 and cap it at 50 - #9603

Merged
bobbai00 merged 3 commits into
apache:mainfrom
bobbai00:feat/agent-default-step-limit
Nov 25, 2026
Merged

bobbai00 merged 3 commits into
apache:mainfrom
bobbai00:feat/agent-default-step-limit

Conversation

@bobbai00

@bobbai00 bobbai00 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Lowers the agent's default limit on model calls (steps) per message from 100 to 25 (maxSteps in agent-service/src/types/agent.ts). It also caps the limit at 50, the settings dialog's maximum, so a request sent straight to the API can no longer go past it (agent-service/src/server.ts). A looping agent stops only at this limit, so a runaway turn now costs a quarter of the calls. 25 is about twice the largest of 60 measured turns (13 model calls, median 3), so ordinary turns are not cut. Users can still raise it per agent in the settings, up to 50.

Any related issues, documentation, discussions?

Closes #9602
Part of #9576

How was this PR tested?

bun test in agent-service. A new test drives a model that never stops calling tools, without setting maxSteps, and expects the turn to stop after 25 calls. Two route tests send a limit of 51: the creation test expects a 400 and no new agent, and the settings test expects a 400 and an unchanged limit. Both accept 50. All three fail on main.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Fable 5.2, Claude Opus 5.5)

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @mengw15
    You can notify them by mentioning @mengw15 in a comment.

@codecov-commenter

codecov-commenter commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.68%. Comparing base (a1b5aad) to head (46fc2e9).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9603   +/-   ##
=========================================
  Coverage     91.68%   91.68%           
  Complexity     5125     5125           
=========================================
  Files          1305     1305           
  Lines         58211    58222   +11     
  Branches       7594     7594           
=========================================
+ Hits          53371    53382   +11     
  Misses         2933     2933           
  Partials       1907     1907           
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 69179ad
agent-service 99.56% <100.00%> (+<0.01%) ⬆️
amber 85.79% <ø> (ø) Carriedforward from 69179ad
computing-unit-managing-service 63.83% <ø> (ø) Carriedforward from 69179ad
config-service 87.50% <ø> (ø) Carriedforward from 69179ad
file-service 82.16% <ø> (ø) Carriedforward from 69179ad
frontend 96.43% <ø> (ø) Carriedforward from 69179ad
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 69179ad
pyamber 98.32% <ø> (ø) Carriedforward from 69179ad
result-service 86.48% <ø> (ø) Carriedforward from 69179ad
workflow-compiling-service 80.90% <ø> (ø) Carriedforward from 69179ad

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bobbai00
bobbai00 requested a review from parshimers November 22, 2026 20:50
@bobbai00

bobbai00 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@sshiv012 could you take a look? This is part of #9576: it lowers the agent's default step limit from 100 to 25.

Also I request @parshimers 's review as you are at collaborator role.

Comment thread agent-service/src/types/agent.ts Resolved
An agent turn could make up to 100 model calls by default, and a
looping agent stops only at that limit. Measured real turns take a
median of 3 calls and at most 13, so 25 leaves room for every one of
them, cuts a runaway turn to a quarter, and fits the 1-50 range the
settings dialog accepts.
@bobbai00
bobbai00 force-pushed the feat/agent-default-step-limit branch from 6caa40c to 2d743c9 Compare November 24, 2026 06:54
@bobbai00
bobbai00 requested a review from kunwp1 November 24, 2026 06:58
The settings dialog stops at 50 steps per message, but the agent service
accepted any limit of 1 or more, so a request sent straight to the API
could let a looping agent make far more model calls. Both routes that
take a step limit, creating an agent and saving its settings, now refuse
anything above 50 with a 400.
@bobbai00 bobbai00 changed the title feat(agent-service): lower the default step limit to 25 feat(agent-service): lower the default step limit to 25 and cap it at 50 Nov 24, 2026

@kunwp1 kunwp1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One optional comment below

The default step limit test built its own looping model. It now uses the
one the step limit notice tests share, which gives up after 50 calls
instead of 20 so the default of 25 fits, and it also checks that the
turn ends with the notice that tells the user why it stopped.
@bobbai00
bobbai00 added this pull request to the merge queue Nov 25, 2026
Merged via the queue into apache:main with commit 6eab748 Nov 25, 2026
23 checks passed
@bobbai00
bobbai00 deleted the feat/agent-default-step-limit branch November 25, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lower the agent's default step limit

4 participants