Skip to content

feat(api): make the ai agent step budget a workflow-global setting#2118

Open
morgan-coded wants to merge 4 commits into
hexabot-ai:mainfrom
morgan-coded:fix/ai-agent-mcp-memory-step-budget
Open

feat(api): make the ai agent step budget a workflow-global setting#2118
morgan-coded wants to merge 4 commits into
hexabot-ai:mainfrom
morgan-coded:fix/ai-agent-mcp-memory-step-budget

Conversation

@morgan-coded

@morgan-coded morgan-coded commented Jul 10, 2026

Copy link
Copy Markdown

stop_step_count was hidden, and its implicit default changed with the number of bound tools, so users could not see or configure a stable limit when a workflow stopped early. The setting is now visible with an advertised default of 10, and an explicit value still wins. Tool-enabled workflows, including those with more than nine tools, now use 10 unless configured higher; tool-less runs and stop_tool_call composition keep their existing behavior. Fixes #1977

Copilot AI review requested due to automatic review settings July 10, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@marrouchi

Copy link
Copy Markdown
Contributor

@morgan-coded Thank you for the contribution! The solution looks good and addresses the immediate issue.

My main concern is that introducing a hard-coded minimum of 10 creates implicit behavior that is not visible or configurable by the end user. At the very least, this would need to be clearly documented. This lack of visibility is one of the reasons we have not addressed the issue yet, we want to avoid replacing one surprising default with another.

How about considering introducing a workflow-level setting that lets users define the maximum tool-call or step count, defaulting to 10. This would provide a sensible default while making the execution budget explicit and configurable for MCP-heavy workflows.

What do you think about this approach? I see this as both a UX and DX concern: users should not have to understand an internal hard-coded constant when debugging why an agent stopped before completing its task.

@morgan-coded morgan-coded changed the title fix(api): expand ai agent default step budget for mcp memory flows feat(api): make the ai agent step budget an explicit setting Jul 12, 2026
@morgan-coded

Copy link
Copy Markdown
Author

Thanks, that makes sense. Reworked the step budget as a visible workflow setting with a default of 10; an explicit value still wins, and the tool-count formula plus the MCP-and-memory-only floor are gone. Tool-enabled workflows now default to 10 even when they expose more than nine tools, so larger budgets need to be set explicitly. The focused tests, API checks, and full workspace checks are passing.

@yassinedorbozgithub yassinedorbozgithub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @morgan-coded, do you think adding a UI message would help users understand what's happening during the final stage of the execution?

},
}),
stop_step_count: z.int().positive().optional().meta({
title: 'Stop step count',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @morgan-coded, do think adding a max value .max(MAX_AI_STEP_BUDGET) can maybe help to avoid any accidental runaway costs

@morgan-coded

Copy link
Copy Markdown
Author

Capped stop_step_count at 100 in the settings schema, while keeping the default at 10 and accepting configured values through the boundary. I used 10× the default to leave headroom for longer workflows while rejecting accidental four- or five-digit budgets; happy to tune that ceiling if you prefer a different value. Kept the final-stage UI message out of this revision so the cap stays focused, and can follow up with it separately if you'd like.

@yassinedorbozgithub

Copy link
Copy Markdown
Collaborator

Capped stop_step_count at 100 in the settings schema, while keeping the default at 10 and accepting configured values through the boundary. I used 10× the default to leave headroom for longer workflows while rejecting accidental four- or five-digit budgets; happy to tune that ceiling if you prefer a different value. Kept the final-stage UI message out of this revision so the cap stays focused, and can follow up with it separately if you'd like.

Hi @morgan-coded, thank you 🙏 for being reactive ⚡
Sure no problem, with follow upping "the reached max step count" UI error message separately in a new PR.

Please don't forget @marrouchi's feedback about making DEFAULT_AI_STEP_BUDGET a workflow global setting
image

@morgan-coded

Copy link
Copy Markdown
Author

Implemented @marrouchi's workflow-global default. There's now an AI agent settings group with default_ai_step_budget set to 10 by default, and the AI actions use it whenever stop_step_count isn't set on the action.

The per-action value still takes precedence, and the 100-step cap is unchanged. Because this is a new settings group, bootstrap seeding adds it to existing installs without a migration.

I'm keeping the "reached max step count" UI message in a separate follow-up PR as agreed.

@yassinedorbozgithub

Copy link
Copy Markdown
Collaborator

@morgan-coded, i can't see stop_step_count as global setting after your changes 🧑‍💻
image

@morgan-coded

Copy link
Copy Markdown
Author

Placed it as a site-wide AI agent settings group, so it lives under the main Settings rather than the workflow's Global Settings dialog — which is why it's missing from your screenshot. From that view you want it beside Timeout/Retries and overridable per step, which makes sense; I can move it there.

Concretely that means adding the step-budget field to the shared workflow settings schema (BaseSettingsSchema) so it renders in that dialog, with the AI actions reading the default from the workflow settings instead of a global one. The per-action stop_step_count override and the 100 cap would stay as-is.

One thing worth your call: that puts an AI-specific field into the generic workflow settings next to Timeout/Retries. Good to go that route, or would you rather it stay AI-scoped somewhere else?

@yassinedorbozgithub

Copy link
Copy Markdown
Collaborator

@morgan-coded, yes move them to BaseSettingsSchema double check the global settings UI
and it will be perfect if you can make the PR changes as minimal as possible 🙏

@morgan-coded
morgan-coded force-pushed the fix/ai-agent-mcp-memory-step-budget branch from 58201df to e8da937 Compare July 17, 2026 14:48
@morgan-coded

Copy link
Copy Markdown
Author

Moved stop_step_count into BaseSettingsSchema, so it now renders beside Timeout/Retries in the workflow Global Settings dialog and uses the same per-step Override global settings path. Removed the separate admin ai_settings group, kept the 100-step cap, and rebased the branch onto current main with this follow-up limited to the schema move and its tests. Could you confirm the dialog looks right on your side?

@morgan-coded morgan-coded changed the title feat(api): make the ai agent step budget an explicit setting feat(api): make the ai agent step budget a workflow-global setting Jul 17, 2026
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.

[Issue] AI agent default stop condition undercounts tool-call budget when MCP tools are bound, preventing memory updates

4 participants