Initialization Scripts for Agents
Every session that starts cold pays a tax. The agent reads the same files, retries the same probes, and rediscovers the same paths. An init script pays the tax once and writes the answers into state. Identify the work an agent should never have to redo per session. Build a deterministic init script that probes runtime, dependencies, and repo health. Persist the probe result so the agent reads it instead of re-running checks. Fail loud, fast, and with one place to look when initialization fails. Open a session. The agent guesses the Python version. Guesses the test command. Lists the repo root five times to find the entry point. Tries to import a package that is not installed. Asks the user where the config file lives. By the time it makes a real edit, ten thousand tokens have gone to setup work that should have been a single script. The fix is one initialization script that runs before the agent does anything else and writes a initreport.json the agent reads at startup. A probe failure means halt and surface to the human. No "the agent will figure it out." The whole point of init is to refuse to start when the workbench is broken. Run it twice in a row. The second run should be a no-op except for a…
Initialization Scripts for Agents: Every session that starts cold pays a tax. The agent reads the same files, retries the same probes, and rediscovers the…
This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.
Browse the complete course catalog or open this lesson on GitHub.