Skip to content

StepPersistence cannot resume after completed tool-call boundary #373

Description

@nmoturi

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

  1. Run an agent with StepPersistence and a tool call.
  2. Interrupt the run in before_model_request for the request following the tool call.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions