Skip to content

feat(weaviate): multi-tenancy, search controls, self-hosted connections and quantization - #8324

Open
Duda Nogueira (dudanogueira) wants to merge 4 commits into
crewAIInc:mainfrom
dudanogueira:feat/weaviate-tool-features
Open

Duda Nogueira (dudanogueira) wants to merge 4 commits into
crewAIInc:mainfrom
dudanogueira:feat/weaviate-tool-features

Conversation

@dudanogueira

@dudanogueira Duda Nogueira (dudanogueira) commented Oct 20, 2026 •

Copy link
Copy Markdown

Related issue

Fixes #8323

Stacked on #8322. GitHub can't base a PR on a branch in a fork, so this diff also shows #8322's two commits. Only the last commit, feat(weaviate): multi-tenancy, …, is new here. Once #8322 merges, this diff shrinks to that commit.

Summary

WeaviateVectorSearchTool could only run a fixed hybrid search against Weaviate Cloud, and it required OPENAI_API_KEY even when the collection didn't vectorize with OpenAI.

  • Connection. weaviate_cluster_url and weaviate_api_key are now optional. Without a cluster URL, the tool connects to a self-hosted Weaviate (weaviate_host, weaviate_http_port, weaviate_grpc_port, weaviate_secure). The OpenAI key is optional, and it is merged into headers instead of replacing them.
  • Multi-tenancy. tenant scopes every search to that tenant. It is set on the tool and isn't in the agent's args schema, so an agent can't switch to another tenant.
  • Search controls. search_type (hybrid / near_text / bm25), target_vector, return_properties and filters.
  • Collection creation and quantization.
    • The old create-if-missing branch was dead code, because collections.get always returns a truthy handle. It is now opt-in with create_collection_if_missing, so a typo in collection_name can't silently create an empty collection.
    • vectorizer takes Configure.Vectors.*, so the quantizer (RQ/SQ/BQ/PQ) and vector index config apply at creation. Legacy Configure.Vectorizer.* objects still work and go to vectorizer_config.
    • When the tool creates a multi-tenant collection, it creates the tenant as well. auto_tenant_creation only applies on insert, so without this the first search fails.
    • The run that creates the collection returns no results without querying, because Weaviate rejects searching a collection that has no properties yet.
  • Smaller fixes.
    • The default vectorizer asked OpenAI for nomic-embed-text, which isn't an OpenAI model. It is now text-embedding-3-small.
    • The client is closed even when the search raises.

Behaviour changes for existing users:

  • A missing OPENAI_API_KEY no longer raises.
  • Missing collections are no longer created automatically, which matches what actually happened before.

Things to look at in review:

  • _vector_config_kwargs uses an isinstance check against the private _VectorizerConfigCreate to support legacy configs.
  • Creating the tenant only for collections the tool creates itself. On an existing collection, a missing tenant is left as an error for the caller to see.

Verification

  • Tests added or updated for the changed behavior

  • Relevant tests and quality checks pass locally

  • 24 new mocked tests, 39 in the file. They cover connection selection, the optional OpenAI key, tenant scoping and isolation from the args schema, all three search types with their options, and creation: off by default, opt-in, legacy vs Configure.Vectors, the quantizer reaching the config, and multi-tenant collections with their tenant.

  • The full crewai-tools suite passes (1077 passed, 9 skipped). ruff and mypy are clean on the changed files.

  • Checked end to end against Weaviate 1.39.5 (self-hosted, no OpenAI key):

    • With model2vec and the RQ quantizer, and with Ollama nomic-embed-text + SQ and an Ollama generative model, the tool created the multi-tenant collection and its tenant.
    • On the created collection, I checked the multi-tenancy flag and the quantizer.
    • hybrid, near_text, bm25, return_properties and filters all returned the expected objects.
    • A second tenant's data never appeared in the first tenant's results.

Additional context

Docs updated in en, ar, ko and pt-BR. tool.specs.json is left to the generate-tool-specs workflow.


Note

Medium Risk
Behavior changes (optional OpenAI key, no implicit collection creation, tenant scoping) can break existing Weaviate Cloud setups; multi-tenant and auto-create paths touch live database state when enabled.

Overview
WeaviateVectorSearchTool is expanded from hybrid-only Weaviate Cloud searches into a configurable Weaviate client: optional cloud vs self-hosted connections, optional OPENAI_API_KEY, and best-effort X-Weaviate-Client-Integration telemetry (bumps weaviate-client to ≥4.23.1).

Search behavior adds search_type (hybrid / near_text / bm25), target_vector, return_properties, and filters. tenant is fixed on the tool (not agent args) for multi-tenant isolation. Collection setup is opt-in via create_collection_if_missing, with Configure.Vectors (quantization) while legacy vectorizers still map to vectorizer_config; default embeddings switch to text-embedding-3-small.

Docs are updated in en/ar/ko/pt-BR, and a large mocked test suite covers connection, tenancy, search modes, creation, and integration registration.

Reviewed by Cursor Bugbot for commit a1e723a. Bugbot is set up for automated code reviews on this repo. Configure here.

@strix-security

strix-security Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

This pull request has 222 commits after the last Strix review (82553bb). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.

No security issues found.

Review summary

Reviewed the full diff, focusing on the single production code change in lib/crewai-tools/src/crewai_tools/tools/weaviate_tool/vector_search.py (docs, tests, pyproject.toml and uv.lock were reviewed as non-production or dependency-only changes).

The new query path is safe: the only agent-supplied value is query, which is handed to the Weaviate client API and never concatenated into a query string, shell command, file path, or template. The new search_type, target_vector, return_properties and filters options are operator-set fields and are not part of the tool's args_schema, which still exposes only query; BaseTool.run validates keyword arguments against that schema, so an agent cannot supply them or override tool configuration.

Multi-tenancy scoping holds up: tenant lives on the tool, every search in tenant mode goes through collection.with_tenant(...), and a search without a tenant against a multi-tenant collection errors rather than widening to all tenants, so I found no way to reach another tenant's data. The loosened credential requirements are deliberate and still enforced where they matter — _connect rejects a missing weaviate_api_key for the Weaviate Cloud path, and the OpenAI key is only forwarded as a header when present. Self-hosted connection parameters (weaviate_host, ports, weaviate_secure) are supplied by whoever builds the tool, not by the agent or request data, so they do not constitute an SSRF vector, and the client is now closed even when the search raises.

Static analysis on the changed file (semgrep p/python) returned nothing; bandit flagged only the pre-existing subprocess.run(["uv", "pip", "install", ...]) call in unchanged code, which uses a fixed argument list with no shell or untrusted input. No security vulnerabilities were confirmed in the changed code.

Updated for 82553bb.


Reviewed by Strix
Re-run review · Configure security review settings

@mintlify

mintlify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit ad82940.

Approve preview

Weaviate reads `X-Weaviate-Client-Integration` (since server 1.38.0) to attribute
traffic to the integration that produced it. The tool sent nothing, so CrewAI was
invisible in that telemetry.

Registration goes through `client.integrations.configure` rather than the `headers=`
argument, because that applies the header to the gRPC transport as well as REST --
searches travel over gRPC. It is best-effort: `_IntegrationConfig` is private API, so
a `weaviate-client` without it skips registration instead of breaking the tool.

`MongoDBVectorSearchTool` already identifies CrewAI to its database the same way, via
`DriverInfo(name="CrewAI", version=version("crewai-tools"))`.

Verified against Weaviate 1.39.5: the header arrives on both transports as
`crewai-tools/<version>`.

Adds the first tests for this tool.
Raises the floor from 4.10.2 to the current release. The lock previously resolved
two versions (4.16.2 and 4.21.3) depending on the Python marker; it now resolves
4.23.1 everywhere, which also drops the unused grpcio-health-checking.

4.23.1 still ships `weaviate.connect.integrations._IntegrationConfig`, so the
integration header registration is unchanged; checked live against Weaviate 1.39.5
(header present on REST and gRPC).
…ns and quantization

WeaviateVectorSearchTool could only run a fixed hybrid search against a Weaviate Cloud
cluster, and required an OpenAI key even when the collection did not vectorize with OpenAI.

- Connection: `weaviate_cluster_url` and `weaviate_api_key` are now optional. Without a
  cluster URL the tool connects to a self-hosted Weaviate (`weaviate_host`, ports,
  `weaviate_secure`). `OPENAI_API_KEY` is optional and is merged into `headers`
  instead of replacing them.
- Multi-tenancy: `tenant` scopes every search to that tenant. It is set on the tool,
  not in the agent's args schema, so an agent cannot pick another tenant.
- Search controls: `search_type` (hybrid / near_text / bm25), `target_vector`,
  `return_properties` and `filters`.
- Collection creation: the old create-if-missing branch never ran, because
  `collections.get` always returns a truthy handle. It is now opt-in with
  `create_collection_if_missing`, so a typo in the collection name can't silently
  create an empty collection. `vectorizer` takes `Configure.Vectors.*`, so the
  quantizer (RQ/SQ/BQ/PQ) and index config apply at creation. Legacy
  `Configure.Vectorizer.*` still works. A new multi-tenant collection gets its tenant
  created, because `auto_tenant_creation` only applies on insert. The run that creates
  a collection returns no results, since Weaviate rejects searching a collection that
  has no properties yet.
- The default vectorizer was `text2vec_openai(model="nomic-embed-text")`, which is not
  an OpenAI model. It is now `text-embedding-3-small`.
- The client is closed even when the search raises.

Docs updated in en, ar, ko and pt-BR.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] WeaviateVectorSearchTool: multi-tenancy, search options, self-hosted Weaviate and quantization

1 participant