OnToolsChanged registers a handler that is called when an MCP toolset reports a tool list change outside of a RunStream. This allows the UI to update the tool count immediately.
(handler func(Event))
| 1394 | // reports a tool list change outside of a RunStream. This allows the UI |
| 1395 | // to update the tool count immediately. |
| 1396 | func (r *LocalRuntime) OnToolsChanged(handler func(Event)) { |
| 1397 | r.onToolsChanged = handler |
| 1398 | |
| 1399 | for _, name := range r.team.AgentNames() { |
| 1400 | a, err := r.team.Agent(name) |
| 1401 | if err != nil { |
| 1402 | continue |
| 1403 | } |
| 1404 | for _, ts := range a.ToolSets() { |
| 1405 | if n, ok := tools.As[tools.ChangeNotifier](ts); ok { |
| 1406 | n.SetToolsChangedHandler(r.emitToolsChanged) |
| 1407 | } |
| 1408 | } |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | // emitToolsChanged is the callback registered on MCP toolsets. It re-reads |
| 1413 | // the current agent's full tool list and pushes a ToolsetInfo event. |
nothing calls this directly
no test coverage detected