Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/config/latest/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func (t *Toolset) validate() error {
if t.URL != "" && t.Type != "a2a" && t.Type != "openapi" {
return errors.New("url can only be used with type 'a2a' or 'openapi'")
}
if t.Name != "" && (t.Type != "mcp" && t.Type != "a2a") {
return errors.New("name can only be used with type 'mcp' or 'a2a'")
if t.Name != "" && (t.Type != "mcp" && t.Type != "a2a" && t.Type != "rag") {
return errors.New("name can only be used with type 'mcp', 'a2a', or 'rag'")
}
if t.RAGConfig != nil && t.Type != "rag" {
return errors.New("rag_config can only be used with type 'rag'")
Expand Down
10 changes: 8 additions & 2 deletions pkg/config/rags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func resolveRAGDefinitions(cfg *latest.Config) error {
return fmt.Errorf("agent '%s' references non-existent RAG definition '%s'", agent.Name, ts.Ref)
}

applyRAGDefaults(ts, &def.Toolset)
applyRAGDefaults(ts, &def.Toolset, ts.Ref)
}
}

return nil
}

// applyRAGDefaults fills empty fields in ts from def. Toolset values win.
func applyRAGDefaults(ts, def *latest.Toolset) {
func applyRAGDefaults(ts, def *latest.Toolset, refName string) {
// Clear the ref since it's been resolved
ts.Ref = ""

Expand All @@ -51,4 +51,10 @@ func applyRAGDefaults(ts, def *latest.Toolset) {
if ts.Name == "" {
ts.Name = def.Name
}
// If name is still empty after applying defaults from the definition,
// use the ref key (e.g., "rag1") so that multiple RAG tools get unique
// tool names instead of all defaulting to "rag".
if ts.Name == "" {
ts.Name = refName
}
}
19 changes: 15 additions & 4 deletions pkg/rag/strategy/vector_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,15 @@ func (s *VectorStore) addPathToWatcher(ctx context.Context, path string) error {
}

func (s *VectorStore) watchLoop(ctx context.Context, docPaths []string) {
// Capture watcher reference at goroutine start to avoid racing with Close()
// which sets s.watcher = nil under watcherMu.
s.watcherMu.Lock()
watcher := s.watcher
s.watcherMu.Unlock()
if watcher == nil {
return
}

var debounceTimer *time.Timer
debounceDuration := 2 * time.Second
pendingChanges := make(map[string]bool)
Expand Down Expand Up @@ -929,7 +938,7 @@ func (s *VectorStore) watchLoop(ctx context.Context, docPaths []string) {
slog.Info("File watcher stopped", "strategy", s.name)
return

case event, ok := <-s.watcher.Events:
case event, ok := <-watcher.Events:
if !ok {
return
}
Expand All @@ -940,8 +949,10 @@ func (s *VectorStore) watchLoop(ctx context.Context, docPaths []string) {

if event.Op&fsnotify.Create != 0 {
s.watcherMu.Lock()
if err := s.addPathToWatcher(ctx, event.Name); err != nil {
slog.Debug("Could not watch new path", "path", event.Name, "error", err)
if s.watcher != nil {
if err := s.addPathToWatcher(ctx, event.Name); err != nil {
slog.Debug("Could not watch new path", "path", event.Name, "error", err)
}
}
s.watcherMu.Unlock()
}
Expand Down Expand Up @@ -974,7 +985,7 @@ func (s *VectorStore) watchLoop(ctx context.Context, docPaths []string) {
}
debounceTimer = time.AfterFunc(debounceDuration, processChanges)

case err, ok := <-s.watcher.Errors:
case err, ok := <-watcher.Errors:
if !ok {
return
}
Expand Down
Loading