Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

fix(agents): editing a piece tool keeps its piece version (#17175)

Hazem Adelead190ca4e26
diff --git a/packages/web/src/features/agents/agent-tools/stores/pieces-tools.ts b/packages/web/src/features/agents/agent-tools/stores/pieces-tools.ts
index 64cad3767d9..266ffbe81f3 100644
--- a/packages/web/src/features/agents/agent-tools/stores/pieces-tools.ts
+++ b/packages/web/src/features/agents/agent-tools/stores/pieces-tools.ts
@@ -127,6 +127,7 @@ export const usePieceToolsDialogStore = create<PiecesToolDialogsState>(
selectedAction,
selectedPiece,
predefinedInputs,
+ editingPieceTool,
isPieceAuthSet,
} = get();
@@ -134,6 +135,13 @@ export const usePieceToolsDialogStore = create<PiecesToolDialogsState>(
return null;
}
+ const editingSameAction =
+ editingPieceTool?.pieceMetadata.pieceName === selectedPiece.pieceName &&
+ editingPieceTool.pieceMetadata.actionName === selectedAction.name;
+ const savedVersion = editingSameAction
+ ? editingPieceTool?.pieceMetadata.pieceVersion
+ : undefined;
+
return {
type: AgentToolType.PIECE,
toolName: mcpToolNameUtils.createPieceToolName(
@@ -141,7 +149,7 @@ export const usePieceToolsDialogStore = create<PiecesToolDialogsState>(
selectedAction.name,
),
pieceMetadata: {
- pieceVersion: selectedPiece.pieceVersion,
+ pieceVersion: savedVersion ?? selectedPiece.pieceVersion,
pieceName: selectedPiece.pieceName,
actionName: selectedAction.name,
predefinedInput: predefinedInputs || undefined,