diff --git a/web/app/components/app/configuration/config/agent/agent-tools/__tests__/index.spec.tsx b/web/app/components/app/configuration/config/agent/agent-tools/__tests__/index.spec.tsx index c804857f6ad..79a1c480aec 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/__tests__/index.spec.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/__tests__/index.spec.tsx @@ -454,6 +454,36 @@ describe('AgentTools', () => { expect(formattingDispatcherMock).toHaveBeenCalled() }) + it('should update only the selected tool credential when tools share a provider', async () => { + const { getModelConfig } = renderAgentTools([ + createAgentTool({ + credential_id: 'credential-search', + notAuthor: true, + }), + createAgentTool({ + credential_id: 'credential-translate', + notAuthor: true, + tool_label: 'Translate Tool', + tool_name: 'translate', + }), + ]) + const authorizationButtons = screen.getAllByRole('button', { name: /tools.notAuthorized/ }) + const secondAuthorizationButton = authorizationButtons[1] + if (!secondAuthorizationButton) + throw new Error('Second authorization button not found') + await userEvent.click(secondAuthorizationButton) + settingPanelCredentialId = 'credential-updated' + await userEvent.click(screen.getByRole('button', { name: 'auth-from-panel' })) + + await waitFor(() => { + const tools = getModelConfig().agentConfig.tools as AgentTool[] + expect(tools.map(tool => tool.credential_id)).toEqual([ + 'credential-search', + 'credential-updated', + ]) + }) + }) + it('should reinstate deleted tools after plugin install success event', async () => { const { getModelConfig } = renderAgentTools([ createAgentTool({ diff --git a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx index f918ddd7e7b..a4dc787a0b7 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx @@ -136,7 +136,7 @@ const AgentTools: FC = () => { const handleAuthorizationItemClick = useCallback((credentialId: string) => { const newModelConfig = produce(modelConfig, (draft) => { - const tool = (draft.agentConfig.tools).find((item: any) => item.provider_id === currentTool?.provider_id) + const tool = (draft.agentConfig.tools).find((item: any) => item.provider_id === currentTool?.provider_id && item.tool_name === currentTool?.tool_name) if (tool) (tool as AgentTool).credential_id = credentialId })