mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-08 22:05:08 -05:00
Add block_name support to run_block tool and UI
Updated backend and frontend to support and prefer the use of block_name when executing blocks via run_block. This improves user experience by displaying human-readable block names and aligns API usage hints and documentation accordingly.
This commit is contained in:
@@ -31,8 +31,10 @@ class FindBlockTool(BaseTool):
|
||||
"Search for available blocks by name or description. "
|
||||
"Blocks are reusable components that perform specific tasks like "
|
||||
"sending emails, making API calls, processing text, etc. "
|
||||
"IMPORTANT: Use this tool FIRST to get the block's 'id' before calling run_block. "
|
||||
"The response includes each block's id, required_inputs, and input_schema."
|
||||
"IMPORTANT: Use this tool FIRST to get the block's 'id' "
|
||||
"before calling run_block. "
|
||||
"The response includes each block's id, required_inputs, "
|
||||
"and input_schema."
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -175,8 +177,9 @@ class FindBlockTool(BaseTool):
|
||||
return BlockListResponse(
|
||||
message=(
|
||||
f"Found {len(blocks)} block(s) matching '{query}'. "
|
||||
"To execute a block, use run_block with the block's 'id' field "
|
||||
"and provide 'input_data' matching the block's input_schema."
|
||||
"To execute a block, use run_block with the block's "
|
||||
"'id' and 'name' fields and provide 'input_data' "
|
||||
"matching the block's input_schema."
|
||||
),
|
||||
blocks=blocks,
|
||||
count=len(blocks),
|
||||
|
||||
@@ -325,8 +325,12 @@ class BlockListResponse(ToolResponseBase):
|
||||
count: int
|
||||
query: str
|
||||
usage_hint: str = Field(
|
||||
default="To execute a block, call run_block with block_id set to the block's "
|
||||
"'id' field and input_data containing the required fields from input_schema."
|
||||
default=(
|
||||
"To execute a block, call run_block with block_id set to "
|
||||
"the block's 'id' field, block_name set to the block's 'name' "
|
||||
"field, and input_data containing the required fields from "
|
||||
"input_schema."
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,14 @@ class RunBlockTool(BaseTool):
|
||||
"NEVER guess this - always get it from find_block first."
|
||||
),
|
||||
},
|
||||
"block_name": {
|
||||
"type": "string",
|
||||
"description": (
|
||||
"The block's human-readable 'name' field from "
|
||||
"find_block results. Include this for better user "
|
||||
"experience."
|
||||
),
|
||||
},
|
||||
"input_data": {
|
||||
"type": "object",
|
||||
"description": (
|
||||
@@ -200,8 +208,9 @@ class RunBlockTool(BaseTool):
|
||||
|
||||
return SetupRequirementsResponse(
|
||||
message=(
|
||||
f"Block '{block.name}' requires credentials that are not configured. "
|
||||
"Please set up the required credentials before running this block."
|
||||
f"Block '{block.name}' requires credentials that are "
|
||||
"not configured. Please set up the required credentials "
|
||||
"before running this block."
|
||||
),
|
||||
session_id=session_id,
|
||||
setup_info=SetupInfo(
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
SquaresFourIcon,
|
||||
type Icon,
|
||||
} from "@phosphor-icons/react";
|
||||
import { beautifyString } from "@/lib/utils";
|
||||
|
||||
/**
|
||||
* Maps internal tool names to human-friendly action phrases (present continuous).
|
||||
@@ -108,6 +109,15 @@ export function formatToolArguments(
|
||||
break;
|
||||
|
||||
case "run_block":
|
||||
// Prefer block_name if provided, otherwise fall back to block_id
|
||||
if (args.block_name) {
|
||||
// Beautify and remove redundant "Block" suffix (same pattern as blocks menu)
|
||||
const displayName = beautifyString(args.block_name as string).replace(
|
||||
/ Block$/,
|
||||
"",
|
||||
);
|
||||
return ` "${displayName}"`;
|
||||
}
|
||||
if (args.block_id) {
|
||||
return ` "${args.block_id as string}"`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user