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 · Imaging: chest radiographs
Start from: the imaging kit (how to restore)
Produces: nothing new; this step only reads
Prompt
Read radiology_notes.txt and data_dictionary.md. List the questions I am being asked to answer, and for each one, which files or columns I would need. Say which file each point came from.
Files used: radiology_notes.txt (the request) and data_dictionary.md.
What you should see. Five questions:
- How well does the primary model (
score_all) separate pneumothorax from no pneumothorax, and how certain is that? - Is the primary model really better than the three alternatives, or could the differences be chance?
- Does it work equally well for PA vs AP views, men vs women, and under vs over 65?
- At each model's published operating point, what are sensitivity and specificity, and does any model meet the pilot bar?
- Separately, sort 200 radiology reports into present / absent / uncertain.
The files needed are labels.csv, model_scores.csv (four score columns), and the DICOM headers (view position, sex, age); radiology_reports.csv for question 5. The memo also warns
that the sample was assembled quickly and has not been checked, which hints at what to look for. The data dictionary warns that the model scores are not comparable between models
and that two models may have seen these images in training.
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