#10672·agno

[Bug] Streaming checkpoint="tool-batch" drops a paused tool and completes the run

Author: chaim-turkel-cyeraCreated Sep 30, 2026Updated Sep 30, 2026

Description

With checkpoint="tool-batch" and stream=True, a tool that should pause the run (get_user_input, and any other HITL pause) is wiped off run_response.tools before the pause check. The run is stored COMPLETED with tools=[] and content=None, and no RunPausedEvent is emitted.

The same stream=False call pauses correctly.

_sync_run_response_with_model_response replaces the run's tools with the callback's model_response.tool_executions:

python
if model_response.tool_executions is not None:
    run_response.tools = list(model_response.tool_executions)

On the streaming path that object is the fresh ModelResponse() created at the start of each aresponse_stream loop. tool_executions defaults to [] (default_factory=list), so the is not None check passes and the assignment replaces the run's tools with an empty list.

The paused tool was already appended to run_response.tools while handling ModelResponseEvent.tool_call_paused. The checkpoint callback then runs and drops it. The agent later decides whether to pause with:

python
if any(tool_call.is_paused for tool_call in run_response.tools or []):

That check sees no tools, so the run completes.

The end-of-run update already merges by tool_call_id instead of replacing (update_run_response in agent/_response.py, with a comment that the tool-batch callback has already written tools). The mid-run sync does not.

_sync_team_run_response_with_model_response has the same replacement. It copies child_run_id onto tools that are still in the new list, then assigns run_response.tools = new_tools, so a paused tool missing from the streaming tool_executions list is dropped there too.

Reproduced on 2.6.22. The same assignment is still in v3.0.11 (libs/agno/agno/agent/_run.py, _sync_run_response_with_model_response).

Steps to Reproduce

  1. Run an agent with checkpoint="tool-batch", UserControlFlowTools, and a model that calls get_user_input.
  2. Call arun(..., stream=True, stream_events=True).
  3. Read the stored run.
python
import asyncio
import json
from dataclasses import dataclass
from typing import AsyncGenerator, Iterator, List

from agno.agent import Agent
from agno.db.base import SessionType
from agno.db.sqlite import SqliteDb
from agno.models.base import Model
from agno.models.message import Message
from agno.models.response import ModelResponse
from agno.tools.user_control_flow import UserControlFlowTools


@dataclass
class AskUserModel(Model):
    id: str = "ask"
    name: str = "AskUserModel"
    provider: str = "scripted"

    def _next(self, messages: List[Message]) -> ModelResponse:
        fields = [{"field_name": "clarification", "field_type": "str", "field_description": "What to show?"}]
        return ModelResponse(
            role="assistant",
            tool_calls=[{
                "id": "call_ask",
                "type": "function",
                "function": {
                    "name": "get_user_input",
                    "arguments": json.dumps({"user_input_fields": fields}),
                },
            }],
        )

    def invoke(self, messages, **kwargs):
        return self._next(messages)

    def invoke_stream(self, messages, **kwargs) -> Iterator[ModelResponse]:
        yield self._next(messages)

    async def ainvoke(self, messages, **kwargs):
        return self._next(messages)

    async def ainvoke_stream(self, messages, **kwargs) -> AsyncGenerator[ModelResponse, None]:
        yield self._next(messages)

    def _parse_provider_response(self, response, **kwargs):
        return response

    def _parse_provider_response_delta(self, response):
        return response


async def main() -> None:
    db = SqliteDb(db_file="/tmp/agno-pause-repro.db")
    agent = Agent(
        name="pause-repro",
        model=AskUserModel(),
        db=db,
        tools=[UserControlFlowTools(instructions="Ask the user when unsure.")],
        checkpoint="tool-batch",
        telemetry=False,
        markdown=False,
    )
    events = [
        type(event).__name__
        async for event in agent.arun(
            input="show me", stream=True, stream_events=True, session_id="s1", user_id="u1"
        )
    ]
    stored = db.get_session(session_id="s1", session_type=SessionType.AGENT).runs[-1]
    print(events)
    print(stored.status, stored.content, [(t.tool_name, t.is_paused) for t in (stored.tools or [])])


asyncio.run(main())

Observed output:

['RunStartedEvent', 'ModelRequestStartedEvent', 'ModelRequestCompletedEvent', 'RunContentCompletedEvent', 'RunCompletedEvent']
COMPLETED None []

The same agent with stream=False returns status=paused, tools=[('get_user_input', True)].

Agent Configuration (if applicable)

python
Agent(
    model=...,
    db=SqliteDb(...),
    tools=[UserControlFlowTools(...)],
    checkpoint="tool-batch",
)
# arun(..., stream=True, stream_events=True)

Expected Behavior

The run pauses. A RunPausedEvent is emitted, and the stored run has status=paused with the get_user_input tool still on run.tools (is_paused=True).

Actual Behavior

No RunPausedEvent. The stored run is COMPLETED, content is None, and tools is [].

Screenshots or Logs (if applicable)

events: RunStartedEvent, ModelRequestStartedEvent, ModelRequestCompletedEvent, RunContentCompletedEvent, RunCompletedEvent
status: COMPLETED
tools: []
content: None

Environment

  • OS: macOS
  • Agno Version: 2.6.22 (reproduced). The replacing assignment is still present in v3.0.11.
  • Python: 3.11

Possible Solutions (optional)

Merge into run_response.tools by tool_call_id in _sync_run_response_with_model_response and _sync_team_run_response_with_model_response, the way update_run_response already does. Keep tools that are on the run but missing from the callback's tool_executions list (the paused tool, and tools recorded on earlier batches).

On the streaming path, after_tool_results is also handed a ModelResponse that never received this turn's tool executions. Filling that list before the callback would make the snapshot match the run.

Additional Context

checkpoint_run then sets run_response.status = RunStatus.running and persists that snapshot, so the stored row never records the pause.