Skip to content

Python: [Bug]: Cosmos vector store: eq/ne with a float like 2.0 on an int field give wrong results #10182

Closed

Description

@nniiovoo

Observed Behavior

On an int field, CosmosCollection treats a float operand like 2.0 as a type mismatch. Filter("count", "eq", 2.0) compiles to WHERE false, so it returns nothing. Filter("count", "ne", 2.0) compiles to IS_DEFINED(c["count"]), so it returns every record, including the ones where count is 2. in [2.0] works fine, and ordered filters like gt 1.5 raise a TypeError.

Expected Behavior

Compare the numbers, the same way in already does and InMemoryCollection and DuckDB do: eq 2.0 matches count 2 and ne 2.0 leaves it out. Cosmos stores every JSON number as a double, so c["count"] = 2.0 is a normal comparison there.

Steps to Reproduce

  1. Define a collection with an int data field
  2. Filter it with eq or ne and a float value like 2.0
  3. Look at the generated WHERE clause (or the results)

Minimal Reproduction

from unittest.mock import MagicMock

from agent_framework import Filter, VectorStoreCollectionDefinition, VectorStoreField
from agent_framework_azure_cosmos import CosmosCollection

definition = VectorStoreCollectionDefinition(
    [
        VectorStoreField("key", name="id", type_="str"),
        VectorStoreField("data", name="count", type_="int"),
        VectorStoreField("vector", name="embedding", type_="float", dimensions=2),
    ],
    collection_name="items",
)
container = MagicMock()
container.id = "items"
collection = CosmosCollection(dict, definition=definition, container_client=container)

for flt in (Filter("count", "eq", 2.0), Filter("count", "ne", 2.0), Filter("count", "in", [2.0])):
    print(flt.operator, collection._prepare_filter(flt)[0])

Error Messages and Stack Traces

eq false
ne IS_DEFINED(c["count"])
in (IS_DEFINED(c["count"]) AND NOT IS_NULL(c["count"]) AND ARRAY_CONTAINS(@filter_0, c["count"]))

Package Versions

agent-framework-core 1.25.0, agent-framework-azure-cosmos 1.0.0b261106 (main at 924a6e5)

Python Version

Python 3.12

Operating System

macOS

Regression

No

Additional Context

_filter_value_compatible in _vector_store.py only accepts type(value) is int for int fields, while float fields already accept both. A fix could be to treat int and float fields the same for numeric operands (bools stay rejected). I have a fix with tests and will open a PR.

AI assistance: I used an AI assistant to help find the cause and write this up. I ran the repro myself.

Acknowledgements

  • I searched existing issues and did not find a duplicate.
  • I personally verified this behavior and the reproduction details are authentic.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 9, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    memoryUsage: [Issues, PRs], Target: memory related features
    on Nov 9, 2026
  3. github-actions commented on Nov 9, 2026

    @github-actions
    Contributor

    Reproduced on main (924a6e5) with a minimal check of CosmosCollection._prepare_filter on an int field: eq 2.0 → false, ne 2.0 → IS_DEFINED(c["count"]), gt 1.5 → TypeError, while in [2.0] compiles normally. This matches the report; the cause is the type(value) is int check in _filter_value_compatible (python/packages/azure-cosmos/agent_framework_azure_cosmos/_vector_store.py).

    Support boundary: unclear. I found no maintained spec or doc stating how float operands on int fields should behave, so that scope decision is left to a maintainers. Routed to the azure-cosmos owner; the linked PR #10183 is still open.

    Run: https://github.com/microsoft/agent-framework/actions/runs/42574107530

    Generated by Issue Routing for #10182 · copilot · auto · ~21 AIC · ⌖ ~1 AIC · ⊞ 5.2K · ◷

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

Metadata

Metadata

Labels

memoryUsage: [Issues, PRs], Target: memory related featurespythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowtriageUsage: [Issues], Target: All issues that still need to be triaged

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions