Lecture 8

Agentic AI for Environmental Data Science

Byeong-Hak Choe

SUNY Geneseo

November 2, 2026

Today’s research task

One research artifact you can explain and verify.

  1. Delegate a bounded task.
  2. Inspect what ran.
  3. Defend the result.

Why researchers use agents

Goldsmith-Pinkham's example figure of U.S. homeownership rates by age, with the original Census source note.

An agent-assisted workflow should leave a reproducible figure.

The model and the agent system

Goldsmith-Pinkham diagram showing a user prompting an LLM, the LLM calling tools, and tool results returning to the LLM.

The model chooses a tool action. The application executes it and returns the result.

What makes an AI system agentic?

A goal, available tools, and a feedback loop.

In our example What you supply
Goal Audit a county-day file
Evidence The file and its dictionary
Boundary Preserve raw inputs; report failed checks

A chatbot answer and a project agent

A suggestion

dplyr::left_join(smoke, weather, by = c("GEOID", "date"))

An artifact you can inspect

output/checks/audit.txt
Weather: 7 rows, 6 unique county-day keys
STOP: duplicate key found

A command can run and still produce the wrong dataset.

Ways to use AI for coding

Suggestions · project actions · delegated tasks

Claude terminal screenshot showing two delegated data-exploration tasks from the mortgage example.

Start with one agent and one task in this class.

What actually runs the analysis?

R executes. Codex reads the result. You check it.

Rscript R/01_audit.R
Smoke rows:          6
Weather rows:        7
Weather unique keys: 6
Audit saved; duplicate-key check stopped execution.

The agent’s work cycle

Teaching schematic of Inspect, Plan, Run, Check, and Report, with a repair path from Check back to Plan.

A failed check sends the task back for a justified correction.

An example conversation

Illustrative dialogue

“Run the audit.”

“Show the duplicated records.”

“Propose a fix and a check.”

Each follow-up uses evidence from the previous step.

The context window

Goldsmith-Pinkham illustration of prompts, instructions, selected file reads, tool actions, and responses accumulating in context.

Your prompt is only part of the model’s working context.

Working context and project memory

Working context is temporary. Project records are inspectable.

Save the question Save the decision Save the evidence
project-plan.md lab-notebook.md Scripts and outputs

Compaction carries state forward. Files let you verify it.

A checkpoint before the next task

DECISION: keep negative smoke estimates.
CHECK: weather key is duplicated; no panel accepted.
NEXT: inspect the exact duplicate and document a fix.

Read the checkpoint. Inspect the files. Verify the state.

Illustrative wildfire projects

Course map showing Canadian fire detections, Heavy smoke plume outlines, and June 7, 2023 county surface smoke estimates.

Transportation: smoke and flight operations. Moisture: preseason conditions and burned area.

Applications across environmental data science

One workflow, many environmental questions.

Input Agent artifact Human check
CSV or spatial layer Audit and derived table Keys, units, coverage
Analysis table Figure or baseline model Comparison and interpretation

Smoke, heat, water quality, energy demand, and solar adoption all need these checks.

Research decisions that need your judgment

Unit · exposure · comparison · claim

  • Airport-day and county-day answer different questions.
  • A June 1 forecast needs information available by June 1.
  • A predictive relationship does not establish causation.

You defend the scientific choice.

A suitable system for this class

One workspace. One bounded task. Visible evidence.

project-plan.md     question and definitions
R/                  reproducible scripts
output/checks/      actual checks
lab-notebook.md     decisions and next task

A classmate reviews the artifact before the team accepts it.

The project folder

wildfire-project/
  AGENTS.md
  project-plan.md
  lab-notebook.md
  data/raw/            original inputs
  data/derived/        scripted transformations
  R/                   analysis scripts
  output/checks/       evidence from checks
  output/figures/      rebuildable figures
  report.qmd

A project plan that supplies useful context

Pilot Unit First artifact
Transportation Airport-day Intake audit and episode plot
Moisture Province-year Predictor audit and evaluation split

State the outcome, units, and claim limit before implementation.

The first Codex session

  1. Open a separate copy of the starter.
  2. Confirm the active project instructions.
  3. Run the synthetic audit.
Read AGENTS.md and project-plan.md.
Summarize the inputs and proposed first check.

The student credit pilot

$100

Individual application. Verification required.

Expires 12 months after the grant. Codex usage credits, separate from API credits.

A prompt with a clear finish line

INPUT:  the two synthetic CSV files
OUTPUT: an R script and saved key/missingness audit
CHECK:  preserve raw data; stop on duplicate keys

Done includes the actual check results, including failures.

A real-data audit after the toy example

Course maps of county smoke on multiple June 2023 days, illustrating why date coverage and consistent scales matter.

Audit the June 2023 county-day extract before rebuilding a map.

What belongs in an audit?

Computed toy-data counts: 6 smoke rows, 7 weather rows, and 6 unique weather county-day keys.

The extra weather row must be explained before the join.

Environmental variables measure different things

Teaching schematic separating an active fire, smoke observed aloft by satellite, and ground-level PM2.5 measured near a town.

A fire detection, an overhead plume, and surface exposure are different measurements.

Missing, zero, and negative values

Synthetic smoke values for three county identifiers on June 7 and 8, including the preserved -0.4 estimate.

Keep valid negative estimates. Missing weather remains NA.

A plausible merge error

The raw weather file repeats this exact record.

GEOID Date Temperature Precipitation
06037 2023-06-07 22 °C 0 mm
06037 2023-06-07 22 °C 0 mm

6 smoke rows → 7 joined rows

Inspect the source grain before deciding how to resolve the duplicate.

A key check in R

key <- c("GEOID", "date")
stopifnot(!anyDuplicated(smoke[key]))
stopifnot(!anyDuplicated(weather[key]))

The last line should fail. Save the report before stopping.

Read GEOID as text so 01001 keeps its leading zero.

Transportation: first agent task

Course map comparing Heavy HMS plume overlap with surface smoke above 35 micrograms per cubic meter on June 7, 2023.

Match airports to counties, then use the documented surface-smoke series.

A transportation pilot prompt

Build one row per airport-day for June 2023.
Save scheduled flights, cancellations, and the rate.
Audit the county match and full surface-smoke join.

Output: a checked table and a June 1–15 episode figure.

Flight operations do not directly measure profits.

Transportation design review

What else could explain a disruption?

  • Weather may move smoke and disrupt flights.
  • Visibility can be part of smoke’s mechanism.
  • Airports share regional shocks and network delays.

A predictive model alone cannot identify smoke’s causal effect.

Moisture: first agent task

Forecast date: June 1

Information allowed Outcome to predict
Documented preseason moisture Province-year burned area

Observed summer weather arrives after the forecast date.

Keep the later burned-area/smoke relationship descriptive.

A moisture pilot prompt

Audit predictor units, coverage, and availability.
Use only information known by June 1.
Compare a baseline using held-out years.

Output: feature definitions, an audit, and an evaluation plan.

Fit preprocessing inside each training sample.

Forecast evaluation that respects time

Illustrative rolling evaluation: keep all provinces in a year together.

Evaluation 2020 2021 2022 2023
Predict 2022 Train Train Test Later
Predict 2023 Train Train Train Test

Compare with a training-only baseline. Check sensitivity to 2023.

A literature assistant needs evidence locations

One claim needs one verifiable location.

Source Question Evidence location
Childs et al. (2022) How is surface smoke estimated? Page, section, figure, or table

Use “not found” when the assigned text does not establish the claim.

Writing and thinking with AI assistance

Write the interpretation first.

Check my paragraph against the saved table and figure.
Flag unsupported numbers, units, and causal claims.

Every number should lead back to an output and a script.

Permissions and data access

Enforced boundary Instructions Version history
Sandbox AGENTS.md Git

These controls do different jobs.

A folder or .gitignore does not isolate its contents.

Course data boundaries

  • Use the approved fire, smoke, air-quality, weather, population, and boundary data.
  • Add documented public transportation or moisture inputs for the approved project.
  • Keep passwords, API keys, student records, and restricted microdata out of the agent workspace.
  • Do not request, open, or share 2006–2026 mortality files. The umbrella project remains outcome-blind.

Review before accepting an artifact

Conceptual matrix comparing implementation cost with verification cost, originally credited by Goldsmith-Pinkham to Clifford Russell.

Which tasks are easy to generate but hard to check?

Keeping the pilot manageable

Goldsmith-Pinkham GitHub research example showing scripts, outputs, decision records, and commit history.

Keep each task small enough to review. Save decisions beside the code.

Lab: the duplicated county-day

20-minute lab · synthetic data

  1. Run the audit and explain the failure.
  2. Document a derived-data duplicate fix.
  3. Join and verify six rows with a partner.
Rscript R/01_audit.R

Lab acceptance checks

6 rows · 6 unique keys · 0 unmatched smoke keys

  • Keep 01001 as text.
  • Preserve the missing precipitation value and -0.4 smoke estimate.
  • Record actual checks and your partner’s review.

Exit ticket

One task. One check. One scientific decision.

Name the artifact, an error that could survive a successful run, and a choice you must defend.

Appendix: adapting the mini-series, 1–4

Paul Goldsmith-Pinkham’s installment Transfer to this class
1. Getting started A project folder, durable context, and a bounded first task
2. Empty folder to figure A script that rebuilds a documented smoke figure
3. Documents to structured data Evidence cards from supplied wildfire papers, with locations and spot checks
4. Large datasets Inspect coverage and harmonize a small sample before scaling

Appendix: adapting the mini-series, 5–8

Paul Goldsmith-Pinkham’s installment Transfer to this class
5. Writing and thinking Student interpretation first, then a check against results
6. Skills Save a repeated, tested audit workflow
7. Permissions and sandboxes Explicit access boundaries and approved public data
8. Integration and collaboration Small changes, decision records, sample-loss reports, and traceable outputs

Appendix: what belongs in AGENTS.md?

Use R and project-relative paths.
Read project-plan.md and data/README.md before analysis.
Preserve raw inputs and document derived transformations.
Check keys, units, missingness, and sample losses.
Keep claims tied to sources and generated outputs.
State what actually ran and what remains unresolved.
Use public, approved data; exclude 2006–2026 mortality.
Complete bounded local work within the authorized task.
Ask before changing the scientific scope or spending money.

Keep instructions short enough that students can understand and maintain them.

Appendix: skills after a successful first workflow

Goldsmith-Pinkham illustration defining a skill as reusable instructions for a repeated workflow.

Begin with a tested audit. Package it only after you understand its checks.

Appendix: a review prompt

Review this artifact without editing files.
Read the question, data definitions, script, and output.
Check the observation unit, keys, missingness, and units.
Look for leakage or unsupported causal language.
Recompute one reported value from the supplied inputs.
Report each material issue with file/line or output location.
Distinguish verified problems from questions and suggestions.
Do not treat a successful run as proof of validity.

Give the reviewer the actual evidence, including failed checks.

Appendix: adapting the instructor’s system

Existing Co-Author practice Undergraduate version
Research strategy and project memory One project plan and one lab notebook
Data engineering and provenance Immutable inputs, documented scripts, source manifest
Claim-source map Each claim linked to a source or generated output
Creator and critic roles Student/Codex implementation plus classmate review
Quality gates Concrete checks with observable evidence

Specialized roles, hooks, dashboards, and journal submission workflows can wait.

Appendix: a two-student rollout

Stage Deliverable Instructor review
First session Synthetic audit and corrected join Can the student explain every check?
Next project task One real input audited Are data access and definitions settled?
First analysis Reproducible figure or baseline forecast Do claims match the design?
Pilot review Short account of usage, corrections, and review time What helped, and what should change?

Expand the system when the project produces a clear reason to do so.

Appendix: sources and further reading