Skip to content

Fix rag init context cancel#2114

Merged
dgageot merged 2 commits intodocker:mainfrom
gtardif:fix_rag_init_context_cancel
Mar 16, 2026
Merged

Fix rag init context cancel#2114
dgageot merged 2 commits intodocker:mainfrom
gtardif:fix_rag_init_context_cancel

Conversation

@gtardif
Copy link
Contributor

@gtardif gtardif commented Mar 16, 2026

Allow to ctrl-C or kill nicely docker-agent when it's using RAG with long-running initialisation

gtardif added 2 commits March 16, 2026 09:38
Assisted-By: docker-agent

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
@gtardif gtardif requested a review from a team as a code owner March 16, 2026 08:47
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Review Summary

Assessment: 🟢 APPROVE

Summary

This PR successfully implements context cancellation support for RAG initialization, allowing graceful shutdown with ctrl-C or kill signals. The implementation follows Go best practices:

Context Threading: Context parameter properly threaded through the entire call chain from top-level functions (Initialize, CollectFiles, DirectoryTree) down to helper functions (addPathToWatcher)

Cancellation Checks: All context checks use proper select statements with context.Done() and default cases to prevent blocking

Loop Protection: Context checks in file iteration loops prevent runaway operations during long-running directory traversals

Test Coverage: New test file collect_cancellation_test.go includes both cancellation and timeout scenarios

Backward Compatibility: All existing callers updated to pass context, including test files using t.Context() which is the correct pattern

The changes are well-structured and address the stated goal of allowing graceful shutdown during long-running RAG initialization.

Findings

No bugs found in the changed code.

@dgageot dgageot merged commit fda4ec4 into docker:main Mar 16, 2026
8 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