Files
ragflow/internal/harness/core/react.go
Yingfeng 706e0d2d06 Refactor harness framework (#16271)
### What problem does this PR solve?

- Tools management
- Pregel engine wrapper for better usage
- UT race
- Coding style

### Type of change

- [x] Refactoring
2026-06-23 20:18:04 +08:00

41 lines
1.1 KiB
Go

package core
import "ragflow/internal/harness/core/schema"
// TypedReActAgentState is the exported state type for ReActAgent middlewares.
type TypedReActAgentState[M MessageType] struct {
Messages []M
ToolInfos []*schema.ToolInfo
DeferredToolInfos []*schema.ToolInfo
Extra map[string]any
RemainingIterations int
}
type ReActAgentState = TypedReActAgentState[*schema.Message]
func NewReActAgentState[M MessageType](msgs []M, tools []*schema.ToolInfo, maxIter int) *TypedReActAgentState[M] {
return &TypedReActAgentState[M]{
Messages: msgs, ToolInfos: tools,
RemainingIterations: maxIter, Extra: make(map[string]any),
}
}
// ReActAgentContext is passed to BeforeAgent middlewares.
type ReActAgentContext struct {
Instruction string
Tools []Tool
ReturnDirectly map[string]bool
ToolSearchTool *schema.ToolInfo
}
// ToolContext provides metadata about a tool being wrapped.
type ToolContext struct {
Name string
CallID string
}
// ToolCallsContext contains metadata about completed tool calls.
type ToolCallsContext struct {
ToolCalls []ToolContext
}