agent broke the notebook when it tried to execute a cell with missing input file
Fixes an agent breaking a notebook by executing a cell with a missing input file: validate inputs before executing anything. For agent builders.
TL;DR
An agent that executes a cell referencing a file that does not exist gets a loud FileNotFoundError at best and a half-mutated notebook at worst. Give the agent a pre-flight: before executing, resolve every input path the notebook references and fail fast with the missing list if any are absent. Never let the agent 'try it and see'; the try can have side effects before the missing file is even reached.
agent broke the notebook when it tried to execute a cell with missing input fileUse this when
- An agent's run fails on FileNotFoundError for an input the notebook expects.
- The notebook was moved, or the data lives elsewhere in automation.
- Cells before the failure had side effects.
Not for this skill when
- The file exists but is unreadable. That is permissions.
- A human hits the missing file. Fix the path yourself.
Steps
- Stop the run and assess: which cells executed before the failure, and did they have side effects? Verify: you know the blast radius.
- Build the pre-flight: the agent scans cell sources for file references and checks existence. Verify: a test notebook with a missing file fails pre-flight.
- Resolve paths against the run's working directory explicitly (no cwd assumptions). Verify: relative paths resolve correctly.
- On missing inputs, the agent reports the missing list and stops before executing anything. Verify: zero cells run on missing inputs.
- Fix the data placement or the paths, then re-run. Verify: pre-flight passes and the run completes.
Variant phrasings
agent missing input file execution
Short form. Pre-flight before executing.
notebook filenotfounderror agent run
The error phrasing. Validate inputs first.
agent execute cell missing data file
General phrasing. Fail fast, execute nothing.
Compatibility: Any notebook runner. The pre-flight is agent-side static analysis.
Why it happens
Notebooks assume their data is where the author left it, and agents execute where they are told, and those two places differ constantly in automation. Executing before validating means the failure lands mid-notebook, after earlier cells may have written outputs, created files, or mutated state. Pre-flight moves the failure to before anything runs, when it is cheap and clean.
Edge cases / pitfalls
- Static scanning misses dynamically constructed paths (f-strings, config files). Also check config-declared inputs.
- A pre-flight that only checks existence misses permission problems. Check readability too.
- The working directory of the agent's kernel may differ from the notebook's directory. Resolve explicitly.
- Do not let the agent 'fix' missing inputs by creating empty files. That converts a clear error into silent wrong results.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Q37AzFQQUKrCM5FPFlhQMQ