Read and summarize text files
Structured plain text is the most reliable medium for language model ingestion. In this exercise, you direct the agent to read local text files directly from the filesystem, synthesize key findings, and attribute claims to specific source files.
Before you start: A project directory containing text-based documents or data files (Setup).
Background
Plain-text formats, including Markdown (.md), CSV (.csv), JSON (.json), LaTeX (.tex), and HTML (.html), are parsed directly as structured token sequences without requiring translation libraries (Inputs).
Directing the agent to inspect files via relative filesystem paths is far superior to pasting excerpts into the chat window: it eliminates manual copy-paste errors, preserves tabular column alignments, and ensures the original file remains the definitive source of truth.
General methodology
Specify the target files and the extraction objective explicitly, instructing the agent to attribute each summary point to its source document.
Read <file1> and <file2>. Synthesize <analytical objective>. For each key finding, cite the specific source file and section.
Requiring explicit file citations transforms conversational claims into an auditable evidence trail (Verification). If the files contain confidential or regulated records, verify that your model endpoint is authorized for that data tier (Privacy and data handling).
Workshop example · Clinical: clinic network
Start from: the data kit (how to restore)
Produces: nothing new; this step only reads
Prompt
Read clinic_notes.txt and data_dictionary.md. List the questions I am being asked to answer, and for each one, which columns or files I would need. Say which file each point came from.
Files used: clinic_notes.txt (an operations memo) and data_dictionary.md.
What you should see. Three questions:
- Which clinics are meeting their HbA1c targets (targets are in
clinic_targets.xlsx)? - Did the Hillcrest follow-up pilot increase HbA1c rechecks, with care about older patients getting more calls, plus a one-page abstract with references?
- If time allows, did Northside's Saturday hours (from March 8) reduce urgent visits?
The columns needed are clinic, hba1c, age, visit_date, and visit_type from clinic_visits.csv, and pilot_calls.csv
for question 2. The memo also warns that the data came from three scheduling systems, which hints at inconsistencies to
look for later.
Verification criteria
- Verified file access: Confirm that the agent executed read commands against each named file in the session transcript.
- Traceable citations: Every claim or numerical parameter in the summary cites a specific file.
- Content fidelity: The summary accurately reflects the text without omitting critical caveats or extrapolating unsupported claims.
Common pitfalls
| Symptom | Underlying cause | Resolution |
|---|---|---|
| Overly generalized summary | The extraction directive was underspecified | Clarify the research objective and specify the required structural format (e.g., bulleted list or markdown table) |
| Unsupported claims | The model hallucinated details from pre-training memory | Direct the agent to quote the exact supporting sentences from the source text and excise unverified points |
Concepts behind this
- Inputs. Language models process information as text. Selecting appropriate ingestion pathways and source formats preserves data structure and prevents extraction errors. Go deeper →
- Verification. Language models can be confidently incorrect. Require empirical evidence, verify mathematical invariants, and use clean-context peer review to audit findings. Go deeper →
Builds on: Orient the agent in a folder