Opens a file on the computer and reads what's inside. Supports plain text, JSON, CSV, YAML, and XML files — so agents can pick up configuration, logs, or work saved from an earlier step.
Opens the file at the supplied path and returns its contents as text, detecting the format from the extension (txt, json, csv, yaml, xml) for appropriate handling. Accepts optional 'offset' and 'limit' parameters to read just a line range — useful for large log files that would otherwise blow through the context window.
When a user asks:
Read the first 50 lines of /var/log/app.log.
the agent calls the tool:
file_read(path="/var/log/app.log", limit=50)and gets back: the first 50 lines of the log file.
Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.
YAML DSL
# log-inspection.yaml
name: log-inspection-crew
process: SEQUENTIAL
agents:
- id: reader
role: Log Reader
goal: Pick up prior state from local files
tools:
- file_read
tasks:
- id: log-inspection-task
agent: reader
description: Read the first 50 lines of /var/log/app.log.Java
import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.FileReadTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
@Autowired ChatClient chatClient;
@Autowired FileReadTool fileReadTool;
Agent reader = Agent.builder()
.role("Log Reader")
.goal("Pick up prior state from local files")
.chatClient(chatClient)
.tool(fileReadTool)
.build();
Task readerTask = Task.builder()
.description("Read the first 50 lines of /var/log/app.log.")
.agent(reader)
.build();
SwarmOutput result = Swarm.builder()
.agent(reader)
.task(readerTask)
.process(ProcessType.SEQUENTIAL)
.build()
.kickoff();Real scenarios where agents put this tool to work.
Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/FileReadTool.java in the swarm-ai repository.