The internal/harness package in RAGFlow provides a standalone Go framework for building stateful multi-agent applications. This framework underpins the Go agent port, enabling advanced behaviors like ReAct reasoning loops, sub-agent delegation, human-in-the-loop interrupts, and persistent checkpointing.
The framework is structured into three layers that bridge the gap between low-level graph execution and high-level chat interactions.
This foundational layer provides the core execution environment for agent workflows, utilizing a graph-based model for state transitions.
eino framework's compose package internal/agent/canvas/scheduler.go32StateGraph pattern. Nodes represent components (e.g., LLM, Retrieval), and edges represent the execution path internal/agent/canvas/scheduler.go32CanvasState can be serialized and managed concurrently using an RWMutex to ensure consistency across execution steps internal/agent/runtime/state.go1-50Sources:
The Agent Development Kit (ADK) provides high-level abstractions for agent logic and tool orchestration.
arxiv, duckduckgo, code_exec, and exesql internal/agent/tool/registry.go33-68parallelNode and Iteration types internal/handler/agent_test.go224-230Sources:
The topmost layer handles real-time interaction, streaming, and external event mapping.
RunAgent, and pushes events (messages, thinking deltas, or errors) back to the client internal/service/agent.go84-91agentMessageDeltaEmitter handles the emission of content and thinking deltas, including the parsing of <think> tags internal/service/agent.go100-113Sources:
The following diagram illustrates how a user request traverses the framework layers to trigger specific code entities.
Diagram: Request Flow through Harness Layers
Sources:
Tools are the primary way agents interact with the outside world. The internal/agent/tool package provides a unified interface for tool registration and invocation.
The registry.go file maintains a map of Factory functions. Each factory captures node-level configuration (like API keys or search limits) and returns an einotool.BaseTool internal/agent/tool/registry.go31-33
| Tool Name | Factory Function | Key Features |
|---|---|---|
retrieval | buildRetrievalTool | Knowledge base search with similarity thresholds internal/agent/tool/registry.go52 |
code_exec | NewCodeExecTool | Sandbox execution for Python/JS internal/agent/tool/registry.go37 |
arxiv | buildArxivTool | Academic paper search with sort/top_n params internal/agent/tool/registry.go35 |
execute_sql | buildExeSQLTool | Secure SQL execution against registered DBs internal/agent/tool/registry.go42 |
email | buildEmailTool | SMTP integration for sending notifications internal/agent/tool/registry.go41 |
keenable | buildKeenableTool | Keenable API integration internal/agent/tool/registry.go49 |
github | buildGitHubTool | GitHub API integration internal/agent/tool/registry.go44 |
pubmed | buildPubMedTool | PubMed search internal/agent/tool/registry.go50 |
wikipedia | buildWikipediaTool | Wikipedia search internal/agent/tool/registry.go65 |
google_scholar | buildGoogleScholarTool | Google Scholar search internal/agent/tool/registry.go46 |
yahoo_finance | buildYahooFinanceTool | Yahoo Finance data retrieval internal/agent/tool/registry.go67 |
To make tools available on the agent canvas, they are wrapped in Component interfaces. For example, retrievalComponent applies DSL-level defaults (like kb_ids) before calling the underlying RetrievalTool internal/agent/component/universe_a_wrappers.go126-138
Diagram: Tool Registry and Adapter Architecture
Sources:
The framework includes several specialized components that handle logic and output:
RetrievalTool while handling legacy input patterns (like UserFillUp) and merging node-level parameters with runtime inputs internal/agent/component/universe_a_wrappers.go126-140The CanvasState is the source of truth during execution. It stores component outputs, user inputs, and global variables. The framework ensures thread-safe access to this state during the asynchronous execution of the graph internal/agent/runtime/state.go1-50
Sources:
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.