Agent V2 `request_limit` is hardcoded to 50 with no way to configure
- Dominant language
- TypeScript
- Stars
- 156k
- Forks
- 24.6k
- Avg merge
- 22h 9m
- Merged PRs (30d)
- 610
Description
### Self Checks
- [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542).
- [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones.
- [x] I confirm that I am using English to submit this report, otherwise it will be closed.
- [x] Please do not modify this template :) and fill in all the required fields.
### 1. Is this request related to a challenge you're experiencing? Tell me about your story.
In Dify 1.16.0 / 1.16.1, the Agent V2 node uses pydantic-ai's `UsageLimits()` which defaults to `request_limit=50`. This means any Agent V2 run that exceeds 50 LLM calls fails with:
```
pydantic_ai.exceptions.UsageLimitExceeded: The next request would exceed the request_limit of 50
```
There is **no way to adjust this value** — not in the UI, not via env vars, not via API parameters.
### Comparison with Agent V1
Agent V1 has `max_iteration` which is:
✅ Configurable in the UI (node settings panel)
✅ Defaults to 10, adjustable up to any value
✅ Stored in `app_config.agent_mode.max_iteration`
Agent V2 has `request_limit`:
❌ Hardcoded to 50 in pydantic-ai library
❌ No UI control
❌ No env var override
❌ No API parameter
### Impact
- Complex Agent workflows that need tool calling + reasoning easily exceed 50 calls
- Users are forced to decompose workflows into smaller agents, which contradicts the "single agent with tools" paradigm
- Community Edition users have no workaround (monkey-patching a third-party library is not acceptable for production)
### Request
Expose `request_limit` (or equivalent) as a configurable parameter in the Agent V2 node settings panel, with a reasonable maximum (e.g. 500).
This should be available in **all editions** (Community / Cloud / Enterprise).
### Additional context
- Dify version: 1.16.1
- The `request_limit` comes from pydantic-ai's `UsageLimits` class: `UsageLimits(request_limit=50)`
- The Agent V2 node creates pydantic-ai agents via `agenton_collections/layers/pydantic_ai/bridge.py`
- Agent V1 `max_iteration` is handled in `web/app/components/app/configuration/config/agent/agent-setting/index.tsx`
- No equivalent setting exists for Agent V2 in `web/features/agent-v2/`
### 2. Additional context or comments
_No response_
### 3. Can you help us with this feature?
- [x] I am interested in contributing to this feature.
Contributor guide
Research direction
Start in agenton_collections/layers/pydantic_ai/bridge.py to trace how UsageLimits is created, then compare the Agent V1 setting in web/app/components/app/configuration/config/agent/agent-setting/index.tsx with the Agent V2 area under web/features/agent-v2/. Done means Agent V2 exposes a request limit in node settings, supports a maximum such as 500, and works across Community, Cloud, and Enterprise editions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- ai, backend, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100