GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Bug]: negative batch_size silently drops inputs in EmbeddingModelBase · Issue #3449 · agentscope-ai/agentscope

[Bug]: negative batch_size silently drops inputs in EmbeddingModelBase #3449

New issue
Copy link
New issue
Copy link
Closed
#3451
Closed
[Bug]: negative batch_size silently drops inputs in EmbeddingModelBase#3449
#3451
Copy link
Assignees
PointerL
Labels
BugSomething doesn't worktriage/confirmedVerified: the reported defect exists

Description

@PointerL
PointerL
opened on Oct 23, 2026
Issue body actions

Prerequisites

  • I have searched the existing issues and discussions, and this is not a duplicate.
  • This is a bug, not a usage question. (For questions, please use Discussions instead.)

Background / Description

I have searched existing issues and PRs, and searched indexed discussions, and found no matching report for EmbeddingModelBase constructor validation.

A custom provider that passes batch_size=-1 to EmbeddingModelBase.__init__ is accepted. Calling it with nonempty inputs then returns an empty EmbeddingResponse without an error or any call to _call_api.

This is an invalid-configuration handling bug in the documented custom-provider extension point. The built-in providers use positive constants; this report does not demonstrate a failure with their defaults.

At main commit bdad647d2fee7d66597681ecd89e086b7800dd2a, the base constructor stores batch_size without validating it. __call__ uses range(0, len(normalized), self.batch_size) to create batches. A negative step produces no batches for nonempty input, and merging those results returns no vectors. A zero batch size instead raises a generic range() error only when called.

Expected: reject nonpositive batch sizes with a clear ValueError at construction, before the object can silently omit outputs.

Error Messages

No error occurs for the negative value. An offline probe using the actual base implementation observed:

| batch_size | Construction | Result for 5 inputs | Provider batch sizes |
| --- | --- | --- | --- |
| -1 | succeeds | 0 embeddings, no exception | none |
| 0 | succeeds | ValueError: range() arg 3 must not be zero | none |
| 1 | succeeds | 5 ordered embeddings | 1, 1, 1, 1, 1 |
| 2 | succeeds | 5 ordered embeddings | 2, 2, 1 |
| 5 | succeeds | 5 ordered embeddings | 5 |

Steps to Reproduce

With this revision installed, save the following as repro.py and run python repro.py. The credential is a dummy value; this subclass performs no network requests.

import asyncio

from agentscope.credential import OpenAICredential
from agentscope.embedding import EmbeddingModelBase, EmbeddingResponse


class LocalEmbedding(EmbeddingModelBase[str]):
    def __init__(self, batch_size):
        super().__init__(
            credential=OpenAICredential(api_key="offline-test-only"),
            model="offline-stub",
            dimensions=1,
            parameters=None,
            context_size=1024,
            batch_size=batch_size,
            max_retries=0,
            retry_delay=0,
        )
        self.calls = []

    async def _call_api(self, inputs, **kwargs):
        self.calls.append(list(inputs))
        return EmbeddingResponse(
            embeddings=[[float(len(item))] for item in inputs],
        )


async def main():
    for size in (-1, 2):
        model = LocalEmbedding(size)
        response = await model(["a", "bb", "ccc", "dddd", "eeeee"])
        print(size, response.embeddings, model.calls)


asyncio.run(main())

Output:

-1 [] []
2 [[1.0], [2.0], [3.0], [4.0], [5.0]] [['a', 'bb'], ['ccc', 'dddd'], ['eeeee']]

Environment

  • AgentScope: 2.0.11dev, main at bdad647d2fee7d66597681ecd89e086b7800dd2a
  • Python: 3.13.9
  • OS: Windows 11
  • Actual source package imported from the checkout; only the provider's _call_api is replaced by the local implementation above.

Proposed scope

Add a positivity check in the base constructor, explain the requirement in its docstring and custom-provider documentation, and cover negative/zero values, positive batching and empty input with offline tests. Constructor-contract tests currently give 2 failures and 4 passes: both invalid sizes are accepted, while positive batching and valid empty input pass.

An alternative is to validate on every call. Constructor validation catches the bad configuration earlier and matches the existing dimensions validation; handling direct mutation of batch_size after construction is outside this proposal.

Related #3341 / #3343 address the analogous issue in MilvusLiteStore, a separate constructor and batching path. The embedding changes in #3380 and #3148 concern usage merging and failed batch cleanup, respectively. Their patches do not add this constructor check.

I would like to contribute this focused fix if the scope is acceptable. Investigation, reproduction and this draft used Codex assistance.

Activity

  1. PointerL
    added
    BugSomething doesn't work
    on Oct 23, 2026
  2. github-actions
    added
    triage/verifyingA bot is verifying whether this bug is real
    triage/confirmedVerified: the reported defect exists
    and removed
    triage/verifyingA bot is verifying whether this bug is real
    on Oct 23, 2026
  3. PointerL commented on Oct 23, 2026

    @PointerL
    PointerL
    on Oct 23, 2026
    ContributorAuthor
    More actions

    /assign

    I'd like to take this focused validation fix: reject nonpositive batch sizes in EmbeddingModelBase, add offline regression tests, and document the constructor requirement. I'll use Codex assistance and review the diff line by line before submitting the PR.

  4. github-actions
    assigned
    PointerL
    on Oct 23, 2026
  5. github-actions commented on Oct 23, 2026

    @github-actions
    github-actionsBot
    on Oct 23, 2026 – with GitHub Actions
    Contributor
    More actions

    It's yours, @PointerL. If there is no pull request and no word from you by 2026-11-06 the claim is released so nobody is blocked — a comment here renews it.

  6. qbc2016
    closed this as completedin #3451on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @PointerL
    PointerL

Labels

BugSomething doesn't worktriage/confirmedVerified: the reported defect exists

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.