Skip to content

Conversation

@orhanrauf
Copy link
Contributor

@orhanrauf orhanrauf commented Nov 4, 2025

Implements validation to limit the number of tokens in search queries.

This prevents excessively long queries, improving performance and preventing potential issues with the underlying search infrastructure. The limit is set to 2048 tokens. Adds token validation to both the new SearchRequest and the legacy LegacySearchRequest schemas.


Summary by cubic

Add a 2048-token limit to search queries to prevent overly long requests and improve performance and stability. Applies to both SearchRequest and LegacySearchRequest.

  • Bug Fixes
    • Enforce token counting using tiktoken (cl100k_base).
    • Reject empty queries in SearchRequest.

Written for commit a5deaf3. Summary will update automatically on new commits.

Implements validation to limit the number of tokens in search queries.

This prevents excessively long queries, improving performance and
preventing potential issues with the underlying search infrastructure.
The limit is set to 2048 tokens. Adds token validation to both the new
`SearchRequest` and the legacy `LegacySearchRequest` schemas.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="backend/airweave/schemas/search_legacy.py">

<violation number="1" location="backend/airweave/schemas/search_legacy.py:47">
Rule violated: **Check for Cursor Rules Drift**

The new 2048-token validator for `LegacySearchRequest.query` is not reflected in `.cursor/rules/search-module.mdc`. Please update the Cursor rule (LegacySearchRequest section) to document the token limit/tokenization so Cursor stays in sync with the code.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@orhanrauf orhanrauf merged commit 17be7e9 into main Nov 4, 2025
11 checks passed
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.

2 participants