Skip to content

feat(agent-service): tell users when the step limit is hit - #9593

Merged
kunwp1 merged 3 commits into
apache:mainfrom
bobbai00:feat/agent-step-limit-notice
Nov 24, 2026
Merged

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

Conversation

@bobbai00

@bobbai00 bobbai00 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

A turn that reaches the step limit now ends with a message from the agent. Before, the chat went quiet.

I stopped because I reached the limit of 25 steps for one message, so the task may be unfinished. Send another message to continue, or raise the limit in the agent's settings.

  • Where: sendMessage in agent-service/src/agent/texera-agent.ts adds it as a closing agent step, as for a stopped or failed turn. The frontend is unchanged.
  • When: only if the loop's stop condition ended the turn. The AI SDK asks it only when the loop would otherwise go on, so a turn that ends for another reason on its last allowed step gets no message.
  • Next turn: the model reads it as the last entry of the earlier task.
  • Stop on the last step: a stop that lands on the last allowed step now ends with "Generation stopped by user.", as one on an earlier step does. Before, that turn ended with no message.

A request that needs four operators, with the step limit set to 3 and a scripted model. Before, the agent stops after three and the chat ends on "Execute 1 tool":

Before: the agent adds three operators, then the chat ends on Execute 1 tool with no message

After, the agent says it stopped at the limit, and "continue" finishes the workflow:

After: the agent says it stopped at the limit of 3 steps, and continue adds the bar chart and finishes

Any related issues, documentation, discussions?

Closes #9592
Part of #9576

How was this PR tested?

  • bun test in agent-service, eight new tests. The message appears at the limit and names the limit the turn started with. It does not appear when the model answers on its last allowed step, a cut-off tool call ends the turn, or the user stops it. A stop on the last allowed step ends as stopped.
  • Live with Claude Haiku 5.5 and a limit of 2: the chat panel showed the message, and "continue" resumed the work.

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

Generated-by: Claude Code (Claude Fable 5.2)

A turn that reaches the step limit ended on a tool call and the chat went quiet. The agent now closes such a turn with a step that says it stopped at the limit and that the user can send another message to continue or raise the limit.
@github-actions

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: @oliarmak-web
    You can notify them by mentioning @oliarmak-web 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.57%. Comparing base (bf6bf9f) to head (c68286d).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9593      +/-   ##
============================================
- Coverage     91.57%   91.57%   -0.01%     
  Complexity     5182     5182              
============================================
  Files          1300     1300              
  Lines         58131    58128       -3     
  Branches       7615     7615              
============================================
- Hits          53235    53232       -3     
  Misses         2958     2958              
  Partials       1938     1938              
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 3121728
agent-service 99.56% <100.00%> (-0.01%) ⬇️
amber 85.46% <ø> (ø) Carriedforward from 3121728
computing-unit-managing-service 63.88% <ø> (ø) Carriedforward from 3121728
config-service 87.50% <ø> (ø) Carriedforward from 3121728
file-service 82.16% <ø> (ø) Carriedforward from 3121728
frontend 96.45% <ø> (ø) Carriedforward from 3121728
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 3121728
pyamber 98.38% <ø> (ø) Carriedforward from 3121728
result-service 85.71% <ø> (ø) Carriedforward from 3121728
workflow-compiling-service 78.30% <ø> (ø) Carriedforward from 3121728

*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.

@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! Left some comments.

Comment thread agent-service/src/agent/texera-agent.ts Resolved
The step-limit notice, the stopped step and the error step differed only in their text. sendMessage now builds all three through one addClosingStep helper.
A stop that landed on the last allowed step let generateText return normally, so the turn ended with no message and sendMessage reported stopped: false. It now ends with "Generation stopped by user.", as a stop on an earlier step does.
@kunwp1
kunwp1 added this pull request to the merge queue Nov 24, 2026
Merged via the queue into apache:main with commit a1b5aad Nov 24, 2026
27 checks passed
const limit = maxSteps === 1 ? "1 step" : `${maxSteps} steps`;
return (
`I stopped because I reached the limit of ${limit} for one message, so the task may be unfinished. ` +
"Send another message to continue, or raise the limit in the agent's settings."

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.

Small follow-up now that this is in: the notice says "raise the limit", but the dialog and now the API stop at 50 and for a looping agent "send another message" just gives it another full budget. Do you think we can say something like "rephrase or break the task down" instead?

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.

Tell the user when the agent stops at its step limit

4 participants