Skip to content
/

Tools

Your first crewChapter 7 of 142 min read

Give an agent file system access to extract contract terms directly from the source agreement rather than relying on parametric memory.


Read a file#

Use FileReadTool from crewai-tools to allow the agent to inspect local documents in summarize.py:

summarize.py
# summarize.py

from crewai import Agent, Crew, Task
from crewai_tools import FileReadTool
from dotenv import load_dotenv

load_dotenv()

read_file = FileReadTool()

summarizer = Agent(
    role="Contract summarizer",
    goal="Turn long contracts into short, accurate summaries that cite the section each point comes from",
    backstory=(
        "You prepare one-page contract briefs for a finance team. You never "
        "guess: every point in your brief comes from the contract text, with "
        "its section number."
    ),
    tools=[read_file],
    verbose=True,
)

summarize_contract = Task(
    description=(
        "Read the contract at {contract_path} and summarize it for the customer. "
        "Cover the term and renewal, fees and payment, service levels, data, "
        "termination, and liability."
    ),
    expected_output="A bulleted summary with one bullet per topic. Each bullet ends with its section number, like (Section 2.2).",
    agent=summarizer,
)

crew = Crew(agents=[summarizer], tasks=[summarize_contract], verbose=True)

if __name__ == "__main__":
    result = crew.kickoff(inputs={"contract_path": "contracts/acme-saas-agreement.md"})
    print(result.raw)

Key implementation points:

  1. Tool assignment: Passing read_file to tools=[read_file] grants the agent permission to invoke the file reader.
  1. Autonomous execution: The task specifies the target path {contract_path}; the agent decides when and how to call the tool.
  1. Citation enforcement: The expected_output requires section numbers for every bullet, ensuring full auditability.

Run the script:

Terminal
(env)$ python summarize.py

The execution log displays a tool execution step calling read_a_files_content, followed by the structured summary:

Output
...
### Data- Customer owns all data uploaded to the Service (Section 5.1).- Provider may only use Customer Data to provide the Service (Section 5.2).- After termination, Customer may export data for 30 days; Provider will delete it  within 90 days of export completion (Section 5.3).

Check the summary#

Compare the data bullet with Section 5.3 of the contract:

  • Contract text: Data deletion occurs within 90 days after the 30-day export period ends (120 days total).
  • Agent summary: Data deletion occurs within 90 days of export completion.

While subtle, the summary misstates the customer's legal retention window. A single agent drafting a summary rarely catches its own omissions. The next chapter introduces a multi-agent review team to verify claims independently.