Skip to content

fix: resolve data races in deferred tools and BM25 strategy, prevent TUI editor panic#3822

Merged
Sayt-0 merged 1 commit into
docker:mainfrom
Piyush0049:fix/concurrency-and-editor-fixes
Jul 24, 2026
Merged

fix: resolve data races in deferred tools and BM25 strategy, prevent TUI editor panic#3822
Sayt-0 merged 1 commit into
docker:mainfrom
Piyush0049:fix/concurrency-and-editor-fixes

Conversation

@Piyush0049

Copy link
Copy Markdown
Contributor

Summary

This PR addresses two critical concurrency safety bugs and one runtime panic condition in the codebase.

Changes Included

  1. Deferred Tools Mutex Fix
    • File: pkg/tools/builtin/deferred/deferred.go
    • Fixed a memory safety bug where ToolSet.Start mutated the deferredTools map while holding only a read lock. Upgraded this to a write lock.
  2. RAG BM25 Strategy Concurrency Protection
    • File: pkg/rag/strategy/bm25.go
    • Added fileHashesMu sync.Mutex to guard concurrent reads and writes to the fileHashes map from background watcher goroutines.
  3. External Editor Slice Panic Guard
    • File: pkg/tui/tui.go
    • Guarded the parser against whitespace-only environment variables which caused index out of bounds panics.

Validation

  • All unit tests in the modified packages passed.
  • Linting ran cleanly with zero issues.

@Piyush0049
Piyush0049 requested a review from a team as a code owner July 24, 2026 08:01
@aheritier aheritier added area/rag For work/issues that have to do with the RAG features area/tools For features/issues/fixes related to the usage of built-in and MCP tools area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Jul 24, 2026
@Sayt-0
Sayt-0 enabled auto-merge July 24, 2026 08:45
@Sayt-0
Sayt-0 merged commit 95cd9f8 into docker:main Jul 24, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/rag For work/issues that have to do with the RAG features area/tools For features/issues/fixes related to the usage of built-in and MCP tools area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants