Skip to content

fix(core): retry workspace search auto-index with context#1257

Merged
omeraplak merged 1 commit intomainfrom
fix/workspace-search-tenant-auto-index
Apr 28, 2026
Merged

fix(core): retry workspace search auto-index with context#1257
omeraplak merged 1 commit intomainfrom
fix/workspace-search-tenant-auto-index

Conversation

@omeraplak
Copy link
Copy Markdown
Member

@omeraplak omeraplak commented Apr 28, 2026

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

Workspace search auto-index starts without operation context and caches the failed attempt. Tenant-aware filesystem backends that require operationContext.conversationId cannot auto-index, and later context-aware searches return no results.

What is the new behavior?

Workspace search auto-index runs lazily and retries after failures, so a later search with operation context can index tenant-scoped files successfully.

fixes #1252

Notes for reviewers

Validated with:

  • pnpm -C packages/core test -- src/workspace/search/index.spec.ts
  • pnpm exec biome check packages/core/src/workspace/search/index.ts packages/core/src/workspace/search/index.spec.ts .changeset/tenant-auto-index-workspace-search.md

Summary by cubic

Fixes auto-indexing in workspace search to retry with operation context. Prevents caching a failed, context-less index for tenant-aware filesystems that require operationContext.conversationId (fixes #1252).

  • Bug Fixes
    • Auto-index runs lazily and retries on the first context-aware search instead of caching a failure.
    • Clears a failed auto-index attempt so future searches can retry; treats “indexed=0 with errors” as a failure.
    • Added tests covering tenant-aware filesystem behavior and context forwarding.

Written for commit 51004a5. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed workspace search auto-indexing for tenant-aware filesystems
    • Improved retry behavior and error handling for failed auto-index operations, preventing stale operations from overwriting recent state

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

🦋 Changeset detected

Latest commit: 51004a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d589e708-8fe4-4c15-8100-c8a99d4a62f4

📥 Commits

Reviewing files that changed from the base of the PR and between 97226de and 51004a5.

📒 Files selected for processing (3)
  • .changeset/tenant-auto-index-workspace-search.md
  • packages/core/src/workspace/search/index.spec.ts
  • packages/core/src/workspace/search/index.ts

📝 Walkthrough

Walkthrough

This change fixes workspace search auto-indexing for tenant-aware filesystems by deferring auto-index initialization from the constructor to lazy evaluation when search is first invoked. This allows the auto-index operation to access the operation context containing tenant information. A test validates that auto-index now correctly handles both failed (no-tenant) and successful (tenant-specific) backend invocations.

Changes

Cohort / File(s) Summary
Changesets Metadata
.changeset/tenant-auto-index-workspace-search.md
Marks @voltagent/core for patch release documenting the auto-index fix for tenant-aware filesystems.
Auto-Index Implementation
packages/core/src/workspace/search/index.ts
Moves auto-index initialization from constructor to lazy ensureAutoIndex method, enabling context-aware indexing. Adds error handling: rejects promise if indexing fails, resets promise state only when current promise fails.
Tenant-Aware Filesystem Test
packages/core/src/workspace/search/index.spec.ts
Adds test case validating auto-index behavior with tenant-aware filesystems; asserts both no-tenant (failed) and tenant-specific (successful) backend invocations occur, and search results are tenant-isolated.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #1035: Introduces context-aware search plumbing (ensureAutoIndex/indexPaths/indexContent) that this fix builds upon for tenant-aware auto-indexing.

Poem

🐰 With lazy ears perked, the index waits—
No rushing in at construction gates!
Now tenant context flows just right,
Auto-indexing shines so bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: implementing lazy retry of workspace search auto-index with operation context for tenant-aware filesystems.
Description check ✅ Passed The PR description includes all required sections from the template: checklist items, current/new behavior explanation, linked issue reference, tests added, and changesets included.
Linked Issues check ✅ Passed The code changes directly address issue #1252 by implementing lazy auto-indexing with context retry, supporting tenant-aware filesystems requiring operationContext.conversationId.
Out of Scope Changes check ✅ Passed All changes are within scope: lazy auto-index implementation, improved error handling, test coverage for tenant-aware filesystem behavior, and required changeset file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/workspace-search-tenant-auto-index

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.

@joggrbot

This comment has been minimized.

Copy link
Copy Markdown
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 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/src/workspace/search/index.ts">

<violation number="1" location="packages/core/src/workspace/search/index.ts:272">
P2: Auto-index retry is skipped on partial failures, so failed files can remain permanently unindexed.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

this.autoIndexPromise = this.indexPaths(this.autoIndexPaths, { context })
const promise = this.indexPaths(this.autoIndexPaths, { context })
.then((summary) => {
if (summary.indexed === 0 && summary.errors.length > 0) {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 28, 2026

Choose a reason for hiding this comment

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

P2: Auto-index retry is skipped on partial failures, so failed files can remain permanently unindexed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/src/workspace/search/index.ts, line 272:

<comment>Auto-index retry is skipped on partial failures, so failed files can remain permanently unindexed.</comment>

<file context>
@@ -276,12 +267,22 @@ export class WorkspaceSearch {
-      this.autoIndexPromise = this.indexPaths(this.autoIndexPaths, { context })
+      const promise = this.indexPaths(this.autoIndexPaths, { context })
+        .then((summary) => {
+          if (summary.indexed === 0 && summary.errors.length > 0) {
+            throw new Error(summary.errors.join("; "));
+          }
</file context>
Fix with Cubic

@omeraplak omeraplak merged commit faeb4ff into main Apr 28, 2026
23 of 24 checks passed
@omeraplak omeraplak deleted the fix/workspace-search-tenant-auto-index branch April 28, 2026 03:00
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.

[BUG] auto-index doesn't work for tenant aware filesystem

1 participant