Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: map agent rounds to react steps (#18868)

buua4367d658ccd17ad
diff --git a/internal/agent/component/agent.go b/internal/agent/component/agent.go
index f3e707cc3c..1285fe47bc 100644
--- a/internal/agent/component/agent.go
+++ b/internal/agent/component/agent.go
@@ -168,6 +168,12 @@ func runEinoReActAgent(ctx context.Context, p AgentParam) (*schema.Message, erro
return nil, fmt.Errorf("build tools: %w", err)
}
input := buildAgentInputMessages(ctx, p)
+ // Eino's MaxStep counts graph nodes, not model calls. One ReAct round
+ // consists of a model decision, a tool node, and the following model
+ // decision that consumes the tool result. Reserve one additional step for
+ // the final model response, so max_rounds=1 can complete a tool call and
+ // produce its answer instead of failing with "exceeds max steps".
+ maxSteps := p.MaxRounds*2 + 1
agent, err := react.NewAgent(ctx, &react.AgentConfig{
ToolCallingModel: chatModel,
@@ -185,7 +191,7 @@ func runEinoReActAgent(ctx context.Context, p AgentParam) (*schema.Message, erro
}
return msgs
},
- MaxStep: p.MaxRounds,
+ MaxStep: maxSteps,
})
if err != nil {
return nil, fmt.Errorf("create react agent: %w", err)