public ActionResult apply(Agent agent, Map<String, String> request) {
        log.debug("Reading file {} for agent {}", request.get("filename"), agent.getId());
        Optional<Document> document = workspace.getDocument(agent.getId(), request.get("filename"));
        if (document.isPresent()) {
            byte[] artifactContent = workspace.getDocumentContent(agent.getId(), request.get("filename"));
            return ActionResult.builder()
                    .status(ActionResult.Status.SUCCESS)
                    .result(new String(artifactContent))
                    .summary(String.format("Successfully read file %s from the agent workspace.", document.get().getName()))
                    .build();
        } else {
            return ActionResult.builder()
                    .status(ActionResult.Status.FAILURE)
                    .summary(String.format("I could not find the file %s in the workspace.", request.get("filename")))
                    .error("File not found.")
                    .build();
        }
    }
@Test
    void testApplyWithExistingFile() {
        String agentId = "agent1";
        String filename = "test.txt";
        String fileContent = "This is a test file.";
        Map<String, String> request = new HashMap<>();
        request.put("filename", filename);

        when(agent.getId()).thenReturn(agentId);
        when(workspace.getDocument(agentId, filename)).thenReturn(Optional.of(Document.builder().name(filename).metadata(Map.of("content-type","text/plain")).build()));
        when(workspace.getDocumentContent(agentId, filename)).thenReturn(fileContent.getBytes());

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

        assertEquals(ActionResult.Status.SUCCESS, result.getStatus());
        assertEquals(fileContent, result.getResult());
        assertEquals("Successfully read file test.txt from the agent workspace.", result.getSummary());
        assertNull(result.getError());

        verify(workspace).getDocument(agentId, filename);
        verify(workspace).getDocumentContent(agentId, filename);
    }