The Go Agent Port is a high-performance, native reimplementation of the RAGFlow agent canvas system. Built using the eino framework, it transitions workflow execution from Python interpretation to a Go-native graph orchestration model. This port includes a DSL (Domain Specific Language) conversion layer, a concurrent runtime state manager, and a comprehensive registry of tools and components.
The Go Agent system provides a native scheduler that handles the complex topology of agent workflows, including parallel execution and loops. It leverages the eino framework for graph construction and the internal/harness package for stateful multi-agent capabilities.
The following diagram bridges the Natural Language Space (User Concepts) to the Code Entity Space (Go Implementation).
Title: Go Agent Runtime Architecture
Sources: internal/service/agent.go35-44 internal/agent/component/universe_a_wrappers.go17-31 internal/agent/runtime/state.go1-20
The system supports two versions of the Agent DSL. The Go port includes a converter to ensure backward compatibility with canvases created in the Python-based editor.
internal/agent/dsl/, it transforms entity.JSONMap structures into executable graph definitions. The AgentService uses dslpkg to handle these transformations during the Compile and Run phases internal/service/agent.go44Sources: internal/handler/agent.go40-41 internal/service/agent.go44
The internal/agent/canvas/ package contains the core logic for building the execution graph and scheduling nodes using the eino framework.
canvas.Runner internal/agent/canvas/scheduler.go1-30 manages the lifecycle of a workflow run, producing SSE events for the frontend.eino-based scheduling logic, handling the transition between nodes internal/agent/canvas/scheduler.go1-30workflowx to handle complex control flows like loops and parallel node execution. The Go port collapses the Python-era LoopItem into the workflowx.AddLoopNode wrapper internal/agent/canvas/loop_subgraph.go1-30agentMessageDeltaEmitter to support <think> tag protocols internal/service/agent.go99-112Sources: internal/service/agent.go99-189 internal/agent/canvas/scheduler.go1-30 internal/agent/canvas/loop_subgraph.go1-30
The Go port implements a modular registry system for components and tools, allowing for dynamic instantiation based on DSL definitions.
internal/agent/component/)Components are the primary building blocks of the canvas. The registry handles P0 and P1 components including agent, begin, llm, retrieval, and switch internal/agent/component/verify_p1_test.go33-38
eino/flow/agent/react internal/agent/component/agent.go2-7 It supports citation grounding via Cite internal/agent/component/agent.go98-104 and history optimization internal/agent/component/agent.go91-92Retrieval and CodeExec that bridge the canvas-facing Component interface to underlying tools internal/agent/component/universe_a_wrappers.go17-25RetrievalStub, TavilySearchStub, ExeSQLStub) that echo stable outputs without requiring network or DB access internal/agent/component/fixture_stubs.go48-180internal/agent/tool/)The tool registry internal/agent/tool/registry.go33-68 manages 20+ built-in tools:
google, duckduckgo, arxiv, wikipedia, searxng, tavily internal/agent/tool/registry.go35-62akshare, yahoo_finance, tushare, jin10 internal/agent/tool/registry.go34-63execute_sql (alias exesql) and code_exec internal/agent/tool/registry.go37-43Sources: internal/agent/component/agent.go68-131 internal/agent/component/message.go31-59 internal/agent/tool/registry.go33-68 internal/agent/component/verify_p1_test.go33-38
The CanvasState in internal/agent/runtime/ manages variable resolution and execution context during a workflow run.
| Entity | Role | Source |
|---|---|---|
runtime.CanvasState | Thread-safe storage for workflow variables using RWMutex. | internal/agent/runtime/state.go1-20 |
ResolveTemplateForDisplay | Resolves Jinja2-style templates for UI display. | internal/agent/component/message.go186-187 |
RunEvent | Event channel for streaming execution updates to the client. | internal/service/agent.go85-86 |
Sources: internal/agent/runtime/state.go1-20 internal/agent/component/message.go166-187 internal/service/agent.go83-86
The Go AgentHandler mirrors the Python API logic, providing endpoints for canvas management and execution while maintaining a hybrid proxy scheme.
Title: Agent API Interaction
Sources: internal/handler/agent.go130-199 internal/service/agent.go67-90
AgentHandler uses AgentService.loadCanvasForUser (via LoadCanvasByID) to ensure users can only access authorized agent resources, mirroring the Python UserCanvasService.get_by_id logic internal/service/agent.go67-72mapAgentError normalizes service-layer errors (e.g., ErrUserCanvasNotFound) into the standard {code, data, message} response envelope used by the frontend internal/handler/agent.go201-208RunAgentWithWebhook allows external payloads to be injected into the Begin component via the execution context as state.Sys["webhook_payload"] internal/service/agent.go73-82agentFileService handles file uploads and URL-based downloads for agent context internal/handler/agent.go49-59WriteChatbotFrame and WriteChatbotRunEvent translate internal RunEvent objects into Python-compatible SSE envelopes for the iframe SDK and frontend React components internal/service/bot_completion.go98-162 internal/service/bot_completion.go181-197Sources: internal/handler/agent.go49-59 internal/handler/agent.go201-208 internal/service/agent.go67-90 internal/service/bot_completion.go98-197
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.