Problem
StepPersistence saves a continuable snapshot after a CallToolsNode, but it currently checks and stores only ctx.messages. At that hook boundary, the ModelRequestNode returned by the tool node has not yet been appended to ctx.messages.
If a worker stops before the next model request, the stored snapshot ends with the assistant tool call but omits the corresponding tool return request. The snapshot is therefore provider-invalid and continue_run() cannot resume it, even though the tool effect is recorded as completed.
Expected behavior
When a CallToolsNode returns a ModelRequestNode, the continuable snapshot should include result.request. A worker interruption immediately after the completed tool boundary should then resume from provider-valid history without repeating the completed tool effect.
Reproduction
- Run an agent with
StepPersistence and a tool call.
- Interrupt the run in
before_model_request for the request following the tool call.
- Call
continue_run() for the interrupted run.
On the current implementation, no continuable provider-valid snapshot exists at that boundary.
Proposed fix
Append result.request to the candidate messages when the completed CallToolsNode returns a ModelRequestNode, then perform the existing provider-validity check and save the snapshot.
Problem
StepPersistencesaves a continuable snapshot after aCallToolsNode, but it currently checks and stores onlyctx.messages. At that hook boundary, theModelRequestNodereturned by the tool node has not yet been appended toctx.messages.If a worker stops before the next model request, the stored snapshot ends with the assistant tool call but omits the corresponding tool return request. The snapshot is therefore provider-invalid and
continue_run()cannot resume it, even though the tool effect is recorded as completed.Expected behavior
When a
CallToolsNodereturns aModelRequestNode, the continuable snapshot should includeresult.request. A worker interruption immediately after the completed tool boundary should then resume from provider-valid history without repeating the completed tool effect.Reproduction
StepPersistenceand a tool call.before_model_requestfor the request following the tool call.continue_run()for the interrupted run.On the current implementation, no continuable provider-valid snapshot exists at that boundary.
Proposed fix
Append
result.requestto the candidate messages when the completedCallToolsNodereturns aModelRequestNode, then perform the existing provider-validity check and save the snapshot.