Files
ragflow/internal/harness/core/react.go
Yingfeng 956357b997 Feat: add harness-go framework —— agent core (#16045)
### What problem does this PR solve?

core module for agent layer built on top of graph engine #16039

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
2026-06-16 11:39:48 +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
}