Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

Implements a new block that concatenates two or more lists into a single list.

  • Two required inputs (list1, list2) for basic use
  • Three optional advanced inputs (list3, list4, list5) for more complex scenarios
  • Preserves element order during concatenation
  • Outputs both the concatenated result and total element count

Test plan

  • Block includes built-in test_input and test_output for automated testing
  • Code passes format and lint checks

Fixes #11139

Add a new block that concatenates two or more lists into a single list.

Features:
- Supports 2 required inputs (list1, list2)
- Supports 3 optional inputs (list3, list4, list5) for advanced use
- Preserves element order during concatenation
- Outputs both the concatenated list and total element count

Fixes Significant-Gravitas#11139

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 requested a review from a team as a code owner January 4, 2026 16:18
@majiayu000 majiayu000 requested review from kcze and ntindle and removed request for a team January 4, 2026 16:18
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Jan 4, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Mutable Defaults

The optional inputs use default=[], which can behave as a shared mutable default depending on how the schema layer instantiates/handles defaults. Prefer using a default_factory=list (or equivalent pattern supported by SchemaField) to avoid unintended cross-instance mutation.

list3: list[Any] = SchemaField(
    description="Optional third list to concatenate",
    default=[],
    advanced=True,
)
list4: list[Any] = SchemaField(
    description="Optional fourth list to concatenate",
    default=[],
    advanced=True,
)
list5: list[Any] = SchemaField(
    description="Optional fifth list to concatenate",
    default=[],
    advanced=True,
)
Input Optionality

The fields list3-list5 are described as optional but are typed as required list[Any] with an empty-list default. If callers explicitly pass null/None (e.g., via JSON), list(None) will raise. Consider typing as list[Any] | None and normalizing to [] (or ensuring the schema forbids None) to make “optional” behavior robust.

    list3: list[Any] = SchemaField(
        description="Optional third list to concatenate",
        default=[],
        advanced=True,
    )
    list4: list[Any] = SchemaField(
        description="Optional fourth list to concatenate",
        default=[],
        advanced=True,
    )
    list5: list[Any] = SchemaField(
        description="Optional fifth list to concatenate",
        default=[],
        advanced=True,
    )

class Output(BlockSchemaOutput):
    concatenated_list: list[Any] = SchemaField(
        description="The concatenated list containing all input list elements"
    )
    total_length: int = SchemaField(
        description="The total number of elements in the concatenated list"
    )

def __init__(self):
    super().__init__(
        id="a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
        description="Concatenates two or more lists into a single list, preserving element order",
        categories={BlockCategory.BASIC},
        input_schema=ConcatenateListsBlock.Input,
        output_schema=ConcatenateListsBlock.Output,
        test_input={"list1": [1, 2, 3], "list2": [4, 5, 6]},
        test_output=[
            ("concatenated_list", [1, 2, 3, 4, 5, 6]),
            ("total_length", 6),
        ],
    )

async def run(self, input_data: Input, **kwargs) -> BlockOutput:
    result = (
        list(input_data.list1)
        + list(input_data.list2)
        + list(input_data.list3)
        + list(input_data.list4)
        + list(input_data.list5)
    )
Efficiency/Clarity

Concatenation currently creates multiple intermediate lists and repeatedly copies. Consider using itertools.chain (or a loop with extend) to reduce intermediate allocations and simplify future expansion to more than five lists.

async def run(self, input_data: Input, **kwargs) -> BlockOutput:
    result = (
        list(input_data.list1)
        + list(input_data.list2)
        + list(input_data.list3)
        + list(input_data.list4)
        + list(input_data.list5)
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🆕 Needs initial review

Development

Successfully merging this pull request may close these issues.

1 participant