Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Expose agent node usage (#24355)
Davide Delbianco0a2111f33de3
diff --git a/api/core/workflow/nodes/agent/agent_node.py b/api/core/workflow/nodes/agent/agent_node.pyindex 2b6382a8a66..419f2ca5502 100644--- a/api/core/workflow/nodes/agent/agent_node.py+++ b/api/core/workflow/nodes/agent/agent_node.py@@ -15,6 +15,7 @@ from core.memory.token_buffer_memory import TokenBufferMemoryfrom core.model_manager import ModelInstance, ModelManagerfrom core.model_runtime.entities.llm_entities import LLMUsagefrom core.model_runtime.entities.model_entities import AIModelEntity, ModelType+from core.model_runtime.utils.encoders import jsonable_encoderfrom core.plugin.entities.request import InvokeCredentialsfrom core.plugin.impl.exc import PluginDaemonClientSideErrorfrom core.plugin.impl.plugin import PluginInstaller@@ -692,7 +693,13 @@ class AgentNode(BaseNode):yield RunCompletedEvent(run_result=NodeRunResult(status=WorkflowNodeExecutionStatus.SUCCEEDED,- outputs={"text": text, "files": ArrayFileSegment(value=files), "json": json_output, **variables},+ outputs={+ "text": text,+ "usage": jsonable_encoder(llm_usage),+ "files": ArrayFileSegment(value=files),+ "json": json_output,+ **variables,+ },metadata={**agent_execution_metadata,WorkflowNodeExecutionMetadataKey.TOOL_INFO: tool_info,diff --git a/web/app/components/workflow/constants.ts b/web/app/components/workflow/constants.tsindex 5bf053e2c53..a17961620b6 100644--- a/web/app/components/workflow/constants.ts+++ b/web/app/components/workflow/constants.ts@@ -467,6 +467,13 @@ export const SUPPORT_OUTPUT_VARS_NODE = [BlockEnum.Agent,]+export const AGENT_OUTPUT_STRUCT: Var[] = [+ {+ variable: 'usage',+ type: VarType.object,+ },+]+export const LLM_OUTPUT_STRUCT: Var[] = [{variable: 'text',diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.tsindex ac9432f69e5..48a5586fcd7 100644--- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts+++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts@@ -24,6 +24,7 @@ import type { VariableAssignerNodeType } from '@/app/components/workflow/nodes/vimport type { Field as StructField } from '@/app/components/workflow/nodes/llm/types'import {+ AGENT_OUTPUT_STRUCT,HTTP_REQUEST_OUTPUT_STRUCT,KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT,LLM_OUTPUT_STRUCT,@@ -498,6 +499,7 @@ const formatItem = (res.vars = [...outputs,...TOOL_OUTPUT_STRUCT,+ ...AGENT_OUTPUT_STRUCT,]break}diff --git a/web/app/components/workflow/nodes/agent/panel.tsx b/web/app/components/workflow/nodes/agent/panel.tsxindex 67414539440..ec6fb9c506b 100644--- a/web/app/components/workflow/nodes/agent/panel.tsx+++ b/web/app/components/workflow/nodes/agent/panel.tsx@@ -100,6 +100,11 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {type='String'description={t(`${i18nPrefix}.outputVars.text`)}/>+ <VarItem+ name='usage'+ type='object'+ description={t(`${i18nPrefix}.outputVars.usage`)}+ /><VarItemname='files'type='Array[File]'diff --git a/web/i18n/de-DE/workflow.ts b/web/i18n/de-DE/workflow.tsindex e519e19e603..0050986d3e0 100644--- a/web/i18n/de-DE/workflow.ts+++ b/web/i18n/de-DE/workflow.ts@@ -842,6 +842,7 @@ const translation = {transfer_method: 'Übertragungsmethode. Wert ist remote_url oder local_file',},text: 'Von Agenten generierte Inhalte',+ usage: 'Nutzungsinformationen des Modells',json: 'Vom Agenten generiertes JSON',},checkList: {diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.tsindex dbc9b908be7..f4353da24ec 100644--- a/web/i18n/en-US/workflow.ts+++ b/web/i18n/en-US/workflow.ts@@ -894,6 +894,7 @@ const translation = {},outputVars: {text: 'agent generated content',+ usage: 'Model Usage Information',files: {title: 'agent generated files',type: 'Support type. Now only support image',diff --git a/web/i18n/es-ES/workflow.ts b/web/i18n/es-ES/workflow.tsindex 47b96427618..fcab9c2731b 100644--- a/web/i18n/es-ES/workflow.ts+++ b/web/i18n/es-ES/workflow.ts@@ -843,6 +843,7 @@ const translation = {},json: 'JSON generado por el agente',text: 'Contenido generado por el agente',+ usage: 'Información de uso del modelo',},checkList: {strategyNotSelected: 'Estrategia no seleccionada',diff --git a/web/i18n/fa-IR/workflow.ts b/web/i18n/fa-IR/workflow.tsindex 146cbc3ee58..567f70cd1fa 100644--- a/web/i18n/fa-IR/workflow.ts+++ b/web/i18n/fa-IR/workflow.ts@@ -842,6 +842,7 @@ const translation = {type: 'نوع پشتیبانی. اکنون فقط از تصویر پشتیبانی می کند',},text: 'محتوای تولید شده توسط عامل',+ usage: 'اطلاعات استفاده از مدل',json: 'عامل JSON را تولید کرد',},checkList: {diff --git a/web/i18n/fr-FR/workflow.ts b/web/i18n/fr-FR/workflow.tsindex a5cc58a8d15..3874ff67488 100644--- a/web/i18n/fr-FR/workflow.ts+++ b/web/i18n/fr-FR/workflow.ts@@ -843,6 +843,7 @@ const translation = {},json: 'JSON généré par l’agent',text: 'Contenu généré par l’agent',+ usage: 'Informations sur l’utilisation du modèle',},checkList: {strategyNotSelected: 'Stratégie non sélectionnée',diff --git a/web/i18n/hi-IN/workflow.ts b/web/i18n/hi-IN/workflow.tsindex c0c2efdd1a2..b04d232e301 100644--- a/web/i18n/hi-IN/workflow.ts+++ b/web/i18n/hi-IN/workflow.ts@@ -862,6 +862,7 @@ const translation = {title: 'एजेंट द्वारा उत्पन्न फ़ाइलें',},text: 'एजेंट द्वारा उत्पन्न सामग्री',+ usage: 'मॉडल उपयोग जानकारी',json: 'एजेंट द्वारा उत्पन्न जेसन',},checkList: {diff --git a/web/i18n/it-IT/workflow.ts b/web/i18n/it-IT/workflow.tsindex c77c934c001..80c695cc6f8 100644--- a/web/i18n/it-IT/workflow.ts+++ b/web/i18n/it-IT/workflow.ts@@ -868,6 +868,7 @@ const translation = {upload_file_id: 'Carica l\'ID del file',},text: 'Contenuto generato dall\'agente',+ usage: 'Informazioni sull\'utilizzo del modello',json: 'JSON generato dall\'agente',},checkList: {diff --git a/web/i18n/ja-JP/workflow.ts b/web/i18n/ja-JP/workflow.tsindex 9e35717363d..06535a85239 100644--- a/web/i18n/ja-JP/workflow.ts+++ b/web/i18n/ja-JP/workflow.ts@@ -882,6 +882,7 @@ const translation = {},text: 'エージェント生成コンテンツ',json: 'エージェント生成の JSON',+ usage: 'モデル使用量',},checkList: {strategyNotSelected: '戦略が選択されていません',diff --git a/web/i18n/ko-KR/workflow.ts b/web/i18n/ko-KR/workflow.tsindex 5a3d2292722..7b2fb779812 100644--- a/web/i18n/ko-KR/workflow.ts+++ b/web/i18n/ko-KR/workflow.ts@@ -885,6 +885,7 @@ const translation = {},json: '에이전트 생성 JSON',text: '상담원이 생성한 콘텐츠',+ usage: '모델 사용 정보',},checkList: {strategyNotSelected: '전략이 선택되지 않음',diff --git a/web/i18n/pl-PL/workflow.ts b/web/i18n/pl-PL/workflow.tsindex 320102d8fd9..9560865e1cf 100644--- a/web/i18n/pl-PL/workflow.ts+++ b/web/i18n/pl-PL/workflow.ts@@ -843,6 +843,7 @@ const translation = {},json: 'Kod JSON wygenerowany przez agenta',text: 'Treści generowane przez agentów',+ usage: 'Informacje o użyciu modelu',},checkList: {strategyNotSelected: 'Nie wybrano strategii',diff --git a/web/i18n/pt-BR/workflow.ts b/web/i18n/pt-BR/workflow.tsindex 27f84c007dd..9e4b2dd4454 100644--- a/web/i18n/pt-BR/workflow.ts+++ b/web/i18n/pt-BR/workflow.ts@@ -843,6 +843,7 @@ const translation = {},json: 'JSON gerado pelo agente',text: 'Conteúdo gerado pelo agente',+ usage: 'Informações de uso do modelo',},checkList: {strategyNotSelected: 'Estratégia não selecionada',diff --git a/web/i18n/ro-RO/workflow.ts b/web/i18n/ro-RO/workflow.tsindex bc23b83916e..3bda159d447 100644--- a/web/i18n/ro-RO/workflow.ts+++ b/web/i18n/ro-RO/workflow.ts@@ -842,6 +842,7 @@ const translation = {url: 'Adresa URL a imaginii',},text: 'Conținut generat de agent',+ usage: 'Informații de utilizare a modelului',json: 'JSON generat de agent',},checkList: {diff --git a/web/i18n/ru-RU/workflow.ts b/web/i18n/ru-RU/workflow.tsindex d400191c936..bd86004cbeb 100644--- a/web/i18n/ru-RU/workflow.ts+++ b/web/i18n/ru-RU/workflow.ts@@ -842,6 +842,7 @@ const translation = {title: 'Файлы, созданные агентом',},text: 'Контент, генерируемый агентом',+ usage: 'Информация об использовании модели',json: 'JSON, сгенерированный агентом',},checkList: {diff --git a/web/i18n/sl-SI/workflow.ts b/web/i18n/sl-SI/workflow.tsindex c9e4f80f92d..9d57db3344d 100644--- a/web/i18n/sl-SI/workflow.ts+++ b/web/i18n/sl-SI/workflow.ts@@ -882,6 +882,7 @@ const translation = {},json: 'agent generiran json',text: 'vsebina, ki jo je ustvaril agent',+ usage: 'informacije o uporabi modela',},checkList: {strategyNotSelected: 'Strategija ni izbrana',diff --git a/web/i18n/th-TH/workflow.ts b/web/i18n/th-TH/workflow.tsindex b331a49189d..653adbe0b38 100644--- a/web/i18n/th-TH/workflow.ts+++ b/web/i18n/th-TH/workflow.ts@@ -842,6 +842,7 @@ const translation = {type: 'ประเภทการสนับสนุน ตอนนี้รองรับเฉพาะรูปภาพ',},text: 'เนื้อหาที่สร้างตัวแทน',+ usage: 'ข้อมูลการใช้งานรุ่น',json: 'ตัวแทนสร้าง JSON',},checkList: {diff --git a/web/i18n/tr-TR/workflow.ts b/web/i18n/tr-TR/workflow.tsindex b32832cb025..903705a65ab 100644--- a/web/i18n/tr-TR/workflow.ts+++ b/web/i18n/tr-TR/workflow.ts@@ -843,6 +843,7 @@ const translation = {url: 'Resim url\'si',},text: 'Temsilci Tarafından Oluşturulan İçerik',+ usage: 'Model Kullanım Bilgileri',json: 'Aracı tarafından oluşturulan JSON',},checkList: {diff --git a/web/i18n/uk-UA/workflow.ts b/web/i18n/uk-UA/workflow.tsindex 66f170f3069..f051ab990f7 100644--- a/web/i18n/uk-UA/workflow.ts+++ b/web/i18n/uk-UA/workflow.ts@@ -842,6 +842,7 @@ const translation = {title: 'Файли, створені агентом',},text: 'Контент, створений агентом',+ usage: 'Інформація про використання моделі',json: 'Агент згенерував JSON',},checkList: {diff --git a/web/i18n/vi-VN/workflow.ts b/web/i18n/vi-VN/workflow.tsindex 843507f7682..0b2e2e87558 100644--- a/web/i18n/vi-VN/workflow.ts+++ b/web/i18n/vi-VN/workflow.ts@@ -843,6 +843,7 @@ const translation = {},json: 'JSON do tác nhân tạo',text: 'Nội dung do tác nhân tạo',+ usage: 'Thông tin sử dụng mô hình',},checkList: {strategyNotSelected: 'Chiến lược không được chọn',diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.tsindex 95d4d254a3e..daaba921ff0 100644--- a/web/i18n/zh-Hans/workflow.ts+++ b/web/i18n/zh-Hans/workflow.ts@@ -894,6 +894,7 @@ const translation = {},outputVars: {text: 'agent 生成的内容',+ usage: '模型用量信息',files: {title: 'agent 生成的文件',type: '支持类型。现在只支持图片',diff --git a/web/i18n/zh-Hant/workflow.ts b/web/i18n/zh-Hant/workflow.tsindex be9e92c3a78..1105800a76f 100644--- a/web/i18n/zh-Hant/workflow.ts+++ b/web/i18n/zh-Hant/workflow.ts@@ -842,6 +842,7 @@ const translation = {upload_file_id: '上傳檔 ID',},text: '代理生成的內容',+ usage: '模型用量信息',json: '代理生成的 JSON',},checkList: {