public ActionResult apply(Agent agent, Map<String, String> request) {
        log.debug("Writing content to file {}", request.get("filename"));

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

        Document document = workspace.addDocument(agent.getId(), filename, request.get("body").getBytes(), new HashMap<>());

        return ActionResult.builder()
                .status(ActionResult.Status.SUCCESS)
                .summary(String.format("The file %s has been written to the Agent workspace.", request.get("filename")))
                .result(String.format("The file %s has been written to the Agent workspace.", request.get("filename")))
                .documents(Arrays.asList(document))
                .build();
    }
@Test
    void testApplyWithMissingFilename() {
        String agentId = "agent1";
        String fileContent = "This is a test file.";
        Map<String, String> request = new HashMap<>();
        request.put("body", fileContent);

        when(agent.getId()).thenReturn(agentId);

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

        assertEquals(ActionResult.Status.FAILURE, result.getStatus());
        verify(workspace, never()).addDocument(anyString(), anyString(), any(), any());

    }