Skip to content

feat: adding debugging breakpoints to Pipeline and Agent #9611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4b0e2d4
wip: fixing tests
davidsbatista Jul 14, 2025
28c84bf
wip: fixing tests
davidsbatista Jul 14, 2025
ef2e2bc
wip: fixing tests
davidsbatista Jul 14, 2025
9fad9bb
wip: fixing tests
davidsbatista Jul 14, 2025
d8ea64f
Merge branch 'main' into feat/breakpoints
davidsbatista Jul 14, 2025
7c608e0
fixing circular imports
davidsbatista Jul 15, 2025
6b2a1f1
decoupling resume and initial run() for agent
davidsbatista Jul 15, 2025
9030636
adding release notes
davidsbatista Jul 15, 2025
98dee13
re-raising BreakPointException from pipeline.run()
davidsbatista Jul 15, 2025
5da1e01
Merge branch 'main' into feat/breakpoints
davidsbatista Jul 15, 2025
f8bfe4c
fixing imports
davidsbatista Jul 15, 2025
e501e35
Merge branch 'main' into feat/breakpoints
davidsbatista Jul 16, 2025
7551fce
refactor: Refactor suggestions for Pipeline breakpoints (#9614)
sjrl Jul 16, 2025
bbaf309
feat: Add dataclasses to represent a `PipelineSnapshot` and refactore…
sjrl Jul 18, 2025
3b80ec9
Merge branch 'main' into feat/breakpoints
davidsbatista Jul 18, 2025
b87d2b3
feat: saving include_outputs_from intermediate results to `PipelineSt…
davidsbatista Jul 23, 2025
8d43570
Merge branch 'main' into feat/breakpoints
davidsbatista Jul 23, 2025
bc32c23
linting
davidsbatista Jul 23, 2025
ba1fdce
cleaning up
davidsbatista Jul 23, 2025
be0b7c2
avoiding creating PipelineSnapshot for every component run
davidsbatista Jul 23, 2025
6e35b07
Merge branch 'main' into feat/breakpoints
davidsbatista Jul 23, 2025
972c04e
Merge branch 'main' into feat/breakpoints
davidsbatista Jul 23, 2025
2e25b75
removing unecessary code
davidsbatista Jul 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
264 changes: 220 additions & 44 deletions haystack/components/agents/agent.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion haystack/components/tools/tool_invoker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
from functools import partial
from typing import Any, Dict, List, Optional, Set, Union

from haystack import component, default_from_dict, default_to_dict, logging
from haystack.components.agents import State
from haystack.core.component.component import component
from haystack.core.component.sockets import Sockets
from haystack.core.serialization import default_from_dict, default_to_dict, logging
from haystack.dataclasses import ChatMessage, ToolCall
from haystack.dataclasses.streaming_chunk import StreamingCallbackT, StreamingChunk, select_streaming_callback
from haystack.tools import (
Expand Down
29 changes: 28 additions & 1 deletion haystack/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

from typing import Any, Optional, Type
from typing import Any, Dict, Optional, Type


class PipelineError(Exception):
Expand Down Expand Up @@ -89,3 +89,30 @@ class DeserializationError(Exception):

class SerializationError(Exception):
pass


class BreakpointException(Exception):
"""
Exception raised when a pipeline breakpoint is triggered.
"""

def __init__(
self,
message: str,
component: Optional[str] = None,
inputs: Optional[Dict[str, Any]] = None,
results: Optional[Dict[str, Any]] = None,
):
super().__init__(message)
self.component = component
self.inputs = inputs
self.results = results


class PipelineInvalidPipelineSnapshotError(Exception):
"""
Exception raised when a pipeline is resumed from an invalid snapshot.
"""

def __init__(self, message: str):
super().__init__(message)
9 changes: 8 additions & 1 deletion haystack/core/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,9 @@ def _convert_to_internal_format(pipeline_inputs: Dict[str, Any]) -> Dict[str, Di
return inputs

@staticmethod
def _consume_component_inputs(component_name: str, component: Dict, inputs: Dict) -> Dict[str, Any]:
def _consume_component_inputs(
component_name: str, component: Dict, inputs: Dict, is_resume: bool = False
) -> Dict[str, Any]:
"""
Extracts the inputs needed to run for the component and removes them from the global inputs state.

Expand All @@ -1094,6 +1096,11 @@ def _consume_component_inputs(component_name: str, component: Dict, inputs: Dict
for socket_name, socket in component["input_sockets"].items():
socket_inputs = component_inputs.get(socket_name, [])
socket_inputs = [sock["value"] for sock in socket_inputs if sock["value"] is not _NO_OUTPUT_PRODUCED]

# if we are resuming a component, the inputs are already consumed, so we just return the first input
if is_resume:
consumed_inputs[socket_name] = socket_inputs[0]
continue
if socket_inputs:
if not socket.is_variadic:
# We only care about the first input provided to the socket.
Expand Down
Loading
Loading