From 77f6262290b09da2f7c4297488b28b66d5ed2a27 Mon Sep 17 00:00:00 2001 From: Sean Hatfield Date: Thu, 5 Jun 2025 14:46:44 -0700 Subject: [PATCH] Direct output for agent flows (#3873) * wip: create direct output switch on last block and send response to ui * lint * Return flow on direct output enabled prevent new blocks below direct output block Update executor/aibitat to handle skipping of handler outputs * dev build --------- Co-authored-by: Timothy Carambat --- .github/workflows/dev-build.yaml | 2 +- .../Admin/AgentBuilder/AddBlockMenu/index.jsx | 17 +++++++ .../Admin/AgentBuilder/BlockList/index.jsx | 49 +++++++++++++++++++ .../src/pages/Admin/AgentBuilder/index.jsx | 1 + server/utils/agentFlows/executor.js | 12 +++++ server/utils/agentFlows/flowTypes.js | 25 ++++++++++ server/utils/agentFlows/index.js | 21 ++++++-- server/utils/agents/aibitat/index.js | 39 +++++++++++++-- 8 files changed, 157 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dev-build.yaml b/.github/workflows/dev-build.yaml index 0e2e15c3..679cf7e7 100644 --- a/.github/workflows/dev-build.yaml +++ b/.github/workflows/dev-build.yaml @@ -6,7 +6,7 @@ concurrency: on: push: - branches: ['warn-bad-docker-command'] # put your current branch to create a build. Core team only. + branches: ['3872-feat-direct-output-to-chat-from-agent-flows'] # put your current branch to create a build. Core team only. paths-ignore: - '**.md' - 'cloud-deployments/*' diff --git a/frontend/src/pages/Admin/AgentBuilder/AddBlockMenu/index.jsx b/frontend/src/pages/Admin/AgentBuilder/AddBlockMenu/index.jsx index 777f521c..02041825 100644 --- a/frontend/src/pages/Admin/AgentBuilder/AddBlockMenu/index.jsx +++ b/frontend/src/pages/Admin/AgentBuilder/AddBlockMenu/index.jsx @@ -2,7 +2,23 @@ import React, { useRef, useEffect } from "react"; import { Plus, CaretDown } from "@phosphor-icons/react"; import { BLOCK_TYPES, BLOCK_INFO } from "../BlockList"; +/** + * Check if the last configurable block has direct output disabled or undefined + * If this property is true then you cannot add a new block after it. + * @param {Array} blocks - The blocks array + * @returns {Boolean} True if the last configurable block has direct output disabled, false otherwise + */ +function checkIfCanAddBlock(blocks) { + const lastConfigurableBlock = blocks[blocks.length - 2]; + if (!lastConfigurableBlock) return true; + return ( + lastConfigurableBlock?.config?.directOutput === false || + lastConfigurableBlock?.config?.directOutput === undefined + ); +} + export default function AddBlockMenu({ + blocks, showBlockMenu, setShowBlockMenu, addBlock, @@ -22,6 +38,7 @@ export default function AddBlockMenu({ }; }, [setShowBlockMenu]); + if (checkIfCanAddBlock(blocks) === false) return null; return (