Bug Report
File: agent/component/list_operations.py
Description
The _head(n) and _tail(n) methods in ListOperations have an off-by-one / wrong-indexing bug: they return a single-element list instead of a slice of n elements.
Current (buggy) code
def _head(self):
n = self._coerce_n()
if 1 <= n <= len(self.inputs):
outputs = [self.inputs[n - 1]] # ← returns ONE item at index n-1
else:
outputs = []
self._set_outputs(outputs)
def _tail(self):
n = self._coerce_n()
if 1 <= n <= len(self.inputs):
outputs = [self.inputs[-n]] # ← returns ONE item at index -n
else:
outputs = []
self._set_outputs(outputs)
Expected behaviour
_head(n) should return the first n items: self.inputs[:n]
_tail(n) should return the last n items: self.inputs[-n:]
Steps to reproduce
inputs = [1, 2, 3, 4, 5]
# head(3) currently returns [3] (inputs[3-1])
# head(3) should return [1, 2, 3]
# tail(2) currently returns [4] (inputs[-2])
# tail(2) should return [4, 5]
Fix
# _head
outputs = self.inputs[:n]
# _tail
outputs = self.inputs[-n:]
Signed-off-by: Cocoon-Break [email protected]
Bug Report
File:
agent/component/list_operations.pyDescription
The
_head(n)and_tail(n)methods inListOperationshave an off-by-one / wrong-indexing bug: they return a single-element list instead of a slice ofnelements.Current (buggy) code
Expected behaviour
_head(n)should return the first n items:self.inputs[:n]_tail(n)should return the last n items:self.inputs[-n:]Steps to reproduce
Fix
Signed-off-by: Cocoon-Break [email protected]