public ActionResult apply(Agent agent, Map<String, String> request) {
        log.debug("Fetching url {} for agent {}", request.get("url"), agent.getId());

        String url = request.get("url");
        if (url == null || url.isEmpty()) {
            return ActionResult.builder()
                    .status(ActionResult.Status.FAILURE)
                    .summary("The url parameter is missing or has an empty value.")
                    .error("The url parameter is missing or has an empty value.")
                    .build();
        }

        String content;
        try {
            content = webClient.get()
                    .uri(url)
                    .retrieve()
                    .bodyToMono(String.class)
                    .block();
        } catch (WebClientResponseException e) {
            return handleWebFetchError(agent, url, String.format("Could not fetch url, error with http status code %d", e.getStatusCode().value()));
        } catch (Exception e) {
            return handleWebFetchError(agent, url, String.format("Could not fetch url, unexpected error."));
        }

        return ActionResult
                .builder()
                .summary(String.format("Reading content at %s", url))
                .status(ActionResult.Status.SUCCESS)
                .result(formatResult(url, content))
                .build();
    }
@Test
    void testApplyWithWebClientResponseException() {
        String url = "http://example.com";
        Map<String, String> request = new HashMap<>();
        request.put("url", url);

        when(webClient.get()).thenReturn(requestHeadersUriSpec);
        when(requestHeadersUriSpec.uri(url)).thenReturn(requestHeadersUriSpec);
        when(requestHeadersUriSpec.retrieve()).thenReturn(responseSpec);
        when(responseSpec.bodyToMono(String.class)).thenReturn(Mono.error(new WebClientResponseException(404, "Not Found", null, null, null)));

        ActionResult result = rawBrowserAction.apply(agent, request);

        assertEquals(ActionResult.Status.FAILURE, result.getStatus());
        assertEquals("Browsing the web for url http://example.com failed.", result.getSummary());
        assertEquals("Could not fetch url, error with http status code 404", result.getError());
    }