← Table of Contents · Page 251 of 868
LIFECYCLE HOOKS
Part 5 of 11
CONTINUATION HOOKS
Now consider a very different problem.
Sometimes an agent stops too soon.
It may write, "I am not sure how to proceed," or "This seems too complex," and end the run with the task unfinished.
Models sometimes give up after hitting an obstacle, or declare victory prematurely when work is incomplete.
A continuation hook addresses this.
A continuation hook runs when the agent tries to finish, and it checks whether the stopping is justified.
If it detects premature surrender, it re-injects the original goal and a nudge, and lets the loop continue.
The detection can be simple or sophisticated.
A simple version looks for phrases of giving up in the final message.
A better version also checks objective facts, such as whether the success criteria from Chapter 26 are actually met, whether any planned steps remain unfinished, or whether tests are still failing.
The nudge itself should be helpful, not just insistent.
A good nudge restates the goal, summarizes what has been tried, and suggests approaches not yet attempted.
For example: "Remember, your task is still to fix the failing test. You have tried changing the function and updating the data. Three approaches you have not tried are checking the configuration file, reading the library documentation, and running the test with more detailed output."
Continuation hooks must be limited, or they can cause endless loops.
Always cap the number of continuations, for example to three, and tie them to the budgets of Chapter 25.
If the agent still cannot make progress after those attempts, the run should end with an honest failure report, not an infinite cycle of nudges.
There is also a subtle risk.
Pushing a model to continue when the task is truly impossible, or the request is unsafe, can lead it to take bad actions out of desperation.
So continuation hooks should never override safety rules, and a request that the agent refuses on safety grounds should not be nudged to continue.
Advertisement
Read Aloud:
0:00 / 0:00