← Table of Contents · Page 269 of 868
ENDING A RUN
Part 3 of 10
CLEANUP
Cleanup means closing and deleting everything the run created that is no longer needed.
That includes temporary files, open database connections, browser sessions, and sandbox containers.
Think of a camping trip.
A good camper leaves the site as clean as it was found, even if the weather ruined the trip.
Cleanup must run even when the run fails, which is why it is usually placed in a lifecycle hook that always fires, as you saw in Chapter 24.
Cleanup should also remove sensitive data, such as downloaded private files, that should not linger.
WHEN AN AGENT SHOULD STOP AND ASK
Not every ending is a success or a failure.
Sometimes the best ending is a question for a human.
An agent should pause and ask when the request is ambiguous in a way that changes the result, when the next action is irreversible or costly, or when its own confidence is low.
A good question is specific, offers choices, and explains what the agent has already done.
For example, "I found two customer accounts named Maria Lopez, one in Austin and one in Denver, and I have not changed anything yet. Which one did you mean?"
A vague question such as "What should I do?" pushes all the work back onto the person.
The harness should record the pause and keep the run's state safe until the answer arrives, as you saw in Chapter 10.
Advertisement
Read Aloud:
0:00 / 0:00