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
14 changes: 13 additions & 1 deletion pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,23 @@ func (a *Agent) Hooks() *latest.HooksConfig {
// Tools returns the tools available to this agent
func (a *Agent) Tools(ctx context.Context) ([]tools.Tool, error) {
a.ensureToolSetsAreStarted(ctx)
return a.collectTools(ctx)
}

// StartedTools returns tools only from toolsets that have already been started,
// without triggering initialization of unstarted toolsets. This is useful for
// notifications (e.g. MCP tool list changes) that should not block on slow
// toolset startup such as RAG file indexing.
func (a *Agent) StartedTools(ctx context.Context) ([]tools.Tool, error) {
return a.collectTools(ctx)
}

// collectTools gathers tools from all started toolsets plus static tools.
func (a *Agent) collectTools(ctx context.Context) ([]tools.Tool, error) {
var agentTools []tools.Tool
for _, toolSet := range a.toolsets {
if !toolSet.IsStarted() {
// Toolset failed to start; skip it
// Toolset not started; skip it
continue
}
ta, err := toolSet.Tools(ctx)
Expand Down
3 changes: 2 additions & 1 deletion pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,8 @@ func (r *LocalRuntime) emitToolsChanged() {
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
agentTools, err := r.CurrentAgentTools(ctx)
a := r.CurrentAgent()
agentTools, err := a.StartedTools(ctx)
if err != nil {
return
}
Expand Down
Loading