The Agent and Workflow System provides a visual programming environment for creating AI-powered workflows and autonomous agents. It implements a graph-based execution engine that orchestrates component pipelines, manages conversational state, and enables multi-step reasoning with tool use. This system bridges visual workflow design with backend execution through a Domain-Specific Language (DSL).
This system is implemented in both Python (the primary engine) and a Go port using the eino framework for high-performance scheduling and workflow execution. The Go port provides a native, efficient execution environment for agents, leveraging Go's concurrency features.
For information about LLM integration and model management, see LLM Integration System. For details about the REST API layer, see Backend API System.
The workflow system is built on a JSON-based DSL that represents workflows as directed graphs with support for loops and branching. Each workflow is called a "canvas" and is stored as a serialized DSL document.
The DSL consists of components, history, and global state. The Graph class in agent/canvas.py is the primary entity responsible for parsing this structure agent/canvas.py48-87 The frontend represents this visually using a collection of nodes (e.g., beginNode, retrievalNode) and edges.
Components Section: Each component contains:
obj: Component configuration with component_name and params agent/canvas.py53-56downstream: Array of component IDs to execute next agent/canvas.py57upstream: Array of component IDs that precede this component agent/canvas.py58For a detailed explanation of the DSL structure and its evolution, see Canvas Engine and DSL.
Sources: agent/canvas.py48-87
The Graph class agent/canvas.py48 provides the foundation for DSL-based execution. It parses the DSL using normalize_chunker_dsl agent/canvas.py94 instantiates component objects via component_class agent/canvas.py104-114 and manages the execution path.
Graph-to-Code Mapping:
Sources: agent/canvas.py48-114 internal/service/agent.go36-46
Components are the building blocks of workflows. The system uses a factory pattern for dynamic component registration and parameter validation.
Component Entity Space:
ComponentParamBase agent/component/base.py43-54:
update() agent/component/base.py136-186max_retries and delay_after_error for execution resilience agent/component/base.py49-50ComponentBase [agent/component/base.py:28] (referenced in agent/canvas.py:31):
set_output() and get_input().For a detailed look at the component architecture, including the factory pattern and dynamic registration, see Component System Architecture.
Sources: agent/component/base.py43-186 agent/canvas.py30-31 agent/component/llm.py86
The Canvas maintains multiple levels of state and provides a variable resolution system. This system allows components to access global variables, environment variables, and outputs from other components.
Variable Types:
sys.*: System variables (query, user_id, conversation_turns, files, history, date).env.*: User-defined workflow variables.component_id@output_key: Reference to specific component outputs.The variable resolution logic handles both system globals and inter-component references. The Message component resolves these via get_kwargs agent/component/message.py153-180 and _stringify_message_value agent/component/message.py103-143
Python Variable Resolution:
sys.* or env.*, it looks up the value in the globals dictionary agent/canvas.py80-86string_format to resolve variables within prompts agent/component/llm.py129-134Message component supports streaming resolution via _stream() agent/component/message.py188-220Go Variable Resolution:
CanvasState in internal/agent/runtime/state.go with concurrent RWMutex design.For more in-depth information on state management and variable resolution, see State and Variable Management.
Sources: agent/canvas.py80-86 agent/component/message.py103-180 agent/component/llm.py129-134
The Agent component implements the ReAct (Reasoning + Acting) pattern for autonomous multi-step task execution with tool use. This allows agents to dynamically decide which tools to use based on the current task and context.
Agent Component agent/component/agent_with_tools.py74-75:
LLM agent/component/llm.py86 and ToolBase agent/tools/base.py29_load_tool_obj() agent/component/agent_with_tools.py136-148LLMBundle for model-driven tool calling agent/component/agent_with_tools.py114-116MCPServerService agent/component/agent_with_tools.py104-112Tool Calling Infrastructure:
max_rounds for the ReAct loop agent/component/agent_with_tools.py45-72For a comprehensive overview of the Agent component, ReAct loop, and tool system, see Agent Tools and ReAct Loop.
Sources: agent/component/agent_with_tools.py45-148 agent/tools/base.py50-92 agent/component/llm.py86
The execution engine processes components while supporting dynamic branching and streaming responses. This ensures a responsive user experience, especially for long-running LLM operations.
Message component supports asynchronous generation using _stream() agent/component/message.py188 yielding content chunks as variables are resolved.kb_prompt rag/prompts/generator.py139 to inject context into LLM prompts, ensuring they fit within token limits via message_fit_in rag/prompts/generator.py69Categorize component agent/component/categorize.py90 uses LLM classification to determine the next execution path via the _next output agent/component/categorize.py150has_canceled agent/canvas.py36 Components check this status frequently during long-running tasks agent/component/categorize.py102emitAgentMessageEvents internal/service/agent.go93 and agentMessageDeltaEmitter internal/service/agent.go100 to handle thinking protocols and SSE event generation.For detailed information on how workflows are executed and how streaming is handled, see Workflow Execution and Streaming.
Sources: agent/component/message.py188 rag/prompts/generator.py69-139 agent/component/categorize.py90-150 agent/canvas.py36 internal/service/agent.go93-163
canvas.py and the Go-native DSL package (internal/agent/dsl/) with v1/v2 converter.agent/component/) and Go (internal/agent/component/).eino-based Go scheduler (internal/agent/canvas/scheduler.go) with workflowx loop/parallel extensions.sys.*, env.*, component@output), global state management, and context handling. Covers both Python canvas state and the Go CanvasState (internal/agent/runtime/state.go) with its concurrent RWMutex design.internal/agent/tool/) with 20+ built-in tools (arxiv, duckduckgo, code_exec, retrieval, exesql, etc.).Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.