Skip to content

Commit e7d7ecd

Browse files
committed
docs: clarify auto-variadic socket input ordering in connect()
Document the input ordering behavior of auto-promoted lazy variadic sockets in Pipeline.connect() and PipelineBase._make_socket_auto_variadic(). When multiple senders are connected to the same list-typed receiver socket, the items in the resulting list are ordered alphabetically by sender component name (because Pipeline.run() schedules components in alphabetical order for deterministic execution), not by the order in which connect() was called. The docstrings now point users to a dedicated joiner component when they need explicit ordering. fixes #10979
1 parent 91fbd7b commit e7d7ecd

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

haystack/core/pipeline/base.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,13 @@ def connect(self, sender: str, receiver: str) -> "PipelineBase": # noqa: PLR091
446446
If connecting to a component that has several output connections, specify the inputs and output names as
447447
'component_name.connections_name'.
448448
449+
When multiple senders are connected to the same list-typed receiver socket, the socket is
450+
automatically promoted to a lazy-variadic socket so it can accept all of them. The items
451+
in the resulting list are ordered by sender component name (alphabetically), not by the
452+
order in which ``connect()`` was called. If your downstream component depends on a specific
453+
input order, use a dedicated joiner component (for example ``DocumentJoiner``) that lets
454+
you control ordering explicitly.
455+
449456
:param sender:
450457
The component that delivers the value. This can be either just a component name or can be
451458
in the format `component_name.connection_name` if the component has multiple outputs.
@@ -956,6 +963,15 @@ def _make_socket_auto_variadic(
956963
When auto-variadicity is applied, `wrap_input_in_list` is also set to False so that sender output types match
957964
the receiver socket's declared list type directly.
958965
966+
.. note::
967+
When multiple senders are connected to the same auto-variadic socket, the items
968+
in the resulting list are ordered by sender component name (alphabetically), not by
969+
the order in which the connections were declared via ``connect()``. This is because
970+
``Pipeline.run()`` schedules components in alphabetical order so that execution is
971+
deterministic and independent of pipeline insertion order. If your downstream
972+
component is sensitive to the input order, consider using a dedicated joiner
973+
component that lets you control ordering explicitly.
974+
959975
:param component_name:
960976
Name of the component owning the receiver socket, used in error messages.
961977
:param receiver_socket:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
enhancements:
3+
- |
4+
Document the input ordering behavior of auto-promoted lazy variadic sockets in
5+
``Pipeline.connect()`` and ``PipelineBase._make_socket_auto_variadic()``. When
6+
multiple senders are connected to the same list-typed receiver socket, the items
7+
in the resulting list are ordered alphabetically by sender component name (because
8+
``Pipeline.run()`` schedules components in alphabetical order for deterministic
9+
execution), not by the order in which ``connect()`` was called. The docstrings now
10+
point users to a dedicated joiner component when they need explicit ordering.

0 commit comments

Comments
 (0)