Skip to content

dspy/unbounded-react-iters

Pack Severity Fix Versions
DSPy warning none, edit by hand All versions

dspy.ReAct(...) defaults to max_iters=20, allowing runaway tool loops to burn latency and tokens when an explicit iteration cap is not set.

agent = dspy.ReAct("question -> answer", tools=[search_tool])
agent = dspy.ReAct("question -> answer", tools=[search_tool], max_iters=6)

Calls to dspy.ReAct(...) or ReAct(...) that omit max_iters=... (excluding calls forwarding **kwargs).

Pass an explicit max_iters=... limit matched to the task's tool budget.

dspy.ReAct(...) without an explicit max_iters relies on the default of 20 tool iterations. Set max_iters=... explicitly to bound latency and token spend.

See all rules in the DSPy pack.