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

        String url = input.get("url");
        if (url == null || url.isEmpty()) {
            return errorResult("An error occurred while attempting to browse a site", "The url parameter is missing or has an empty value.");
        }

        try {
            return browsePage(url, input.get("query"));
        } catch (Exception e) {
            log.warn("Browsing error for {}", url, e);
            return errorResult(
                    String.format("An error occured while attempting to browse %s", url),
                    "Browsing failed, you should try another site.");
        }
    }
@Test
    void testApplyWithMissingUrl() {
        Map<String, String> input = new HashMap<>();
        input.put("query", "What is this page about?");

        ActionResult result = playwrightBrowserAction.apply(agent, input);

        assertEquals(ActionResult.Status.FAILURE, result.getStatus());
        assertEquals("An error occurred while attempting to browse a site", result.getSummary());
        assertEquals("The url parameter is missing or has an empty value.", result.getError());
    }