File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -209,11 +209,23 @@ func (a *Agent) Hooks() *latest.HooksConfig {
209209// Tools returns the tools available to this agent
210210func (a * Agent ) Tools (ctx context.Context ) ([]tools.Tool , error ) {
211211 a .ensureToolSetsAreStarted (ctx )
212+ return a .collectTools (ctx )
213+ }
214+
215+ // StartedTools returns tools only from toolsets that have already been started,
216+ // without triggering initialization of unstarted toolsets. This is useful for
217+ // notifications (e.g. MCP tool list changes) that should not block on slow
218+ // toolset startup such as RAG file indexing.
219+ func (a * Agent ) StartedTools (ctx context.Context ) ([]tools.Tool , error ) {
220+ return a .collectTools (ctx )
221+ }
212222
223+ // collectTools gathers tools from all started toolsets plus static tools.
224+ func (a * Agent ) collectTools (ctx context.Context ) ([]tools.Tool , error ) {
213225 var agentTools []tools.Tool
214226 for _ , toolSet := range a .toolsets {
215227 if ! toolSet .IsStarted () {
216- // Toolset failed to start ; skip it
228+ // Toolset not started ; skip it
217229 continue
218230 }
219231 ta , err := toolSet .Tools (ctx )
Original file line number Diff line number Diff line change @@ -808,7 +808,8 @@ func (r *LocalRuntime) emitToolsChanged() {
808808 }
809809 ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
810810 defer cancel ()
811- agentTools , err := r .CurrentAgentTools (ctx )
811+ a := r .CurrentAgent ()
812+ agentTools , err := a .StartedTools (ctx )
812813 if err != nil {
813814 return
814815 }
You can’t perform that action at this time.
0 commit comments