Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Doc: code component output section (#14915)

buua43682e06db8c3c0
diff --git a/docs/guides/agent/agent_component_reference/code.mdx b/docs/guides/agent/agent_component_reference/code.mdx
index d0af92cc18..fa1de1caab 100644
--- a/docs/guides/agent/agent_component_reference/code.mdx
+++ b/docs/guides/agent/agent_component_reference/code.mdx
@@ -98,7 +98,49 @@ If you define output variables here, ensure they are also defined in your code i
### Output
-The defined output variable(s) will be auto-populated here.
+The output is split into two parts:
+
+- **Business**: the business output defined in **Return Value**
+- **System**: runtime fields that are populated automatically, such as `content`, `actual_type`, and `attachments`
+
+For example, the following code generates a simple line chart:
+
+```Python
+def main() -> dict:
+ from pathlib import Path
+
+ import matplotlib
+ matplotlib.use("Agg")
+ import matplotlib.pyplot as plt
+
+ artifacts_dir = Path("artifacts")
+ artifacts_dir.mkdir(parents=True, exist_ok=True)
+
+ x = [1, 2, 3, 4, 5]
+ y = [2, 4, 6, 8, 10]
+
+ output_path = artifacts_dir / "simple_plot.png"
+
+ plt.figure(figsize=(6, 4))
+ plt.plot(x, y, marker="o")
+ plt.title("Simple Line Chart")
+ plt.xlabel("X")
+ plt.ylabel("Y")
+ plt.grid(True)
+ plt.tight_layout()
+ plt.savefig(output_path)
+ plt.close()
+
+ return {
+ "result": "plot generated successfully",
+ "file_path": str(output_path),
+ }
+```
+![](https://raw.githubusercontent.com/infiniflow/ragflow-docs/main/images/codeexec_output1.jpg)
+
+Business Output shows the return value you defined, while System Output shows the generated `content`, the inferred `actual_type`, and the collected `attachments`.
+
+![](https://raw.githubusercontent.com/infiniflow/ragflow-docs/main/images/codeexec_output2.jpg)
## Troubleshooting