Skip to content

feat(blocks): add ConcatenateListsBlock for list concatenation#11691

Closed
majiayu000 wants to merge 2 commits intoSignificant-Gravitas:devfrom
majiayu000:feat/list-concatenate-block
Closed

feat(blocks): add ConcatenateListsBlock for list concatenation#11691
majiayu000 wants to merge 2 commits intoSignificant-Gravitas:devfrom
majiayu000:feat/list-concatenate-block

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
Contributor

coderabbitai bot commented Jan 4, 2026

Walkthrough

The PR adds a new ConcatenateListsBlock to the basic blocks module that merges up to five input lists into a single concatenated list, outputting both the combined result and its total length.

Changes

Cohort / File(s) Summary
List Concatenation Block
autogpt_platform/backend/backend/blocks/basic.py
Added ConcatenateListsBlock class with nested Input and Output classes. Accepts five lists (two required: list1, list2; three optional: list3–list5) and uses itertools.chain to concatenate them into a single list. Outputs the concatenated list and its total length. Includes metadata, input/output schemas, and test fixtures.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A furry block of magic brew,
Five lists now merged into one new,
With chain and care, we hop along,
Concatenate our data song! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a new ConcatenateListsBlock for concatenating lists, which is the primary purpose of this pull request.
Description check ✅ Passed The description is directly related to the changeset, providing details about the block's functionality, input/output specifications, and testing approach.
Linked Issues check ✅ Passed The pull request fully implements the requirement from issue #11139 by providing a block that concatenates two or more lists into one with proper input/output handling.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the ConcatenateListsBlock as specified in the linked issue; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 290d0d9 and d36cbe9.

📒 Files selected for processing (1)
  • autogpt_platform/backend/backend/blocks/basic.py
🧰 Additional context used
📓 Path-based instructions (4)
autogpt_platform/backend/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Always run backend setup commands in order: poetry install, poetry run prisma migrate dev, poetry run prisma generate before backend development
Always run poetry run format (Black + isort) before poetry run lint (ruff) for backend code
Use Python 3.10-3.13 with Python 3.11 required for development (managed by Poetry via pyproject.toml)

Run linting and formatting: use poetry run format (Black + isort) to auto-fix, and poetry run lint (ruff) to check remaining errors

Files:

  • autogpt_platform/backend/backend/blocks/basic.py
autogpt_platform/backend/backend/blocks/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Agent blocks in backend/blocks/ must include: block definition with input/output schemas, execution logic with proper error handling, and tests validating functionality. Blocks inherit from Block base class with input/output schemas, implement run method, use uuid.uuid4() for block UUID, and be registered in block registry

Files:

  • autogpt_platform/backend/backend/blocks/basic.py
autogpt_platform/{backend,autogpt_libs}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/blocks/basic.py
autogpt_platform/backend/**

📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)

autogpt_platform/backend/**: Install dependencies for backend using poetry install
Run database migrations using poetry run prisma migrate dev

Files:

  • autogpt_platform/backend/backend/blocks/basic.py
🧠 Learnings (4)
📚 Learning: 2025-11-25T08:48:33.246Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T08:48:33.246Z
Learning: Applies to autogpt_platform/backend/backend/blocks/**/*.py : Agent blocks in backend/blocks/ must include: block definition with input/output schemas, execution logic with proper error handling, and tests validating functionality. Blocks inherit from Block base class with input/output schemas, implement run method, use uuid.uuid4() for block UUID, and be registered in block registry

Applied to files:

  • autogpt_platform/backend/backend/blocks/basic.py
📚 Learning: 2025-11-25T08:49:03.583Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:49:03.583Z
Learning: Applies to autogpt_platform/backend/blocks/**/*.py : Implement async `run` method in block classes for backend

Applied to files:

  • autogpt_platform/backend/backend/blocks/basic.py
📚 Learning: 2025-11-25T08:49:03.583Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:49:03.583Z
Learning: Applies to autogpt_platform/backend/blocks/**/*.py : Inherit from `Block` base class and define input/output schemas using `BlockSchema` for backend blocks

Applied to files:

  • autogpt_platform/backend/backend/blocks/basic.py
📚 Learning: 2025-11-25T08:49:03.583Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:49:03.583Z
Learning: Applies to autogpt_platform/backend/blocks/**/*.py : Generate unique block ID using `uuid.uuid4()` for each new block

Applied to files:

  • autogpt_platform/backend/backend/blocks/basic.py
🧬 Code graph analysis (1)
autogpt_platform/backend/backend/blocks/basic.py (2)
autogpt_platform/backend/backend/data/block.py (3)
  • BlockSchemaInput (339-345)
  • BlockSchemaOutput (348-356)
  • BlockCategory (77-101)
autogpt_platform/backend/backend/data/model.py (1)
  • SchemaField (257-309)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: types
  • GitHub Check: Seer Code Review
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: Check PR Status
🔇 Additional comments (2)
autogpt_platform/backend/backend/blocks/basic.py (2)

1-2: LGTM!

The itertools import is appropriate for the efficient list concatenation implementation.


274-286: LGTM!

The implementation efficiently uses itertools.chain to concatenate lists without creating intermediate copies. The method correctly yields both outputs.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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)
    )

@ntindle
Copy link
Member

ntindle commented Jan 20, 2026

@coderabbitai review

Comment on lines +235 to +249
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,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better way to hanlde this? it seems --- tedious to upkeep

Copy link
Member

@ntindle ntindle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments + tests fail


def __init__(self):
super().__init__(
id="a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regenerate this using python uuid fucntions

Comment on lines 274 to 282
result = (
list(input_data.list1)
+ list(input_data.list2)
+ list(input_data.list3)
+ list(input_data.list4)
+ list(input_data.list5)
)
yield "concatenated_list", result
yield "total_length", len(result)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk man why do we need five vs two vs 3 here?

@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 🚧 Needs work in AutoGPT development kanban Jan 20, 2026
…enateListsBlock

Signed-off-by: Antigravity AI <antigravity@google.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ majiayu000
❌ Antigravity AI


Antigravity AI seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ntindle
Copy link
Member

ntindle commented Jan 20, 2026

we have decide to merge a competing pr. closing: #11567

@ntindle ntindle closed this Jan 20, 2026
@github-project-automation github-project-automation bot moved this from 🚧 Needs work to ✅ Done in AutoGPT development kanban Jan 20, 2026
@majiayu000 majiayu000 deleted the feat/list-concatenate-block branch January 21, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants