Skip to content

Fix RAG retrieving logic and application hang on 0 documents#69

Merged
Gerifield merged 3 commits intomainfrom
fix-rag-retrieve-hang-2904263248769327638
Mar 20, 2026
Merged

Fix RAG retrieving logic and application hang on 0 documents#69
Gerifield merged 3 commits intomainfrom
fix-rag-retrieve-hang-2904263248769327638

Conversation

@Gerifield
Copy link
Owner

Fixes the issue where the application would stop working (hang) if 0 RAG documents were retrieved. Also ensures that the internal counter tracking the number of embedded documents correctly reflects the entire Chromem database count rather than resetting to 0 if no new documents were parsed during startup.


PR created automatically by Jules for task 2904263248769327638 started by @Gerifield

- Update `l.embeddedDocs` calculation in `internal/rag/rag.go` to use `coll.Count()` instead of the number of newly loaded files so that it correctly accounts for already embedded documents.
- Unconditionally pass `ai.WithDocs(ragContextDocs...)` in `internal/ai/agent/logic.go` when generating content, even if the document slice is empty. This prevents a blocking loop/hang in `genkit.Generate` when `SearchEnable` (server-side tools) is enabled but no context documents are explicitly provided to the generation options.

Co-authored-by: Gerifield <195914+Gerifield@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules bot and others added 2 commits March 20, 2026 20:08
- Changed `os.Kill` to `syscall.SIGTERM` in `signal.Notify` and `signal.NotifyContext` calls across application entrypoints (`cmd/server-bot` and `cmd/client-telegram`).
- `os.Kill` (SIGKILL) cannot be caught or intercepted by user-space programs, which resulted in the application terminating immediately upon receiving a stop signal without running its shutdown sequence (such as flushing the RAG database). Using `SIGTERM` resolves this and permits the shutdown routines to complete gracefully.

Co-authored-by: Gerifield <195914+Gerifield@users.noreply.github.com>
@Gerifield Gerifield merged commit 17044ca into main Mar 20, 2026
1 check passed
@Gerifield Gerifield deleted the fix-rag-retrieve-hang-2904263248769327638 branch March 20, 2026 20:26
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.

1 participant