reprobe re-runs ensureToolSetsAreStarted after a batch of tool calls. If new tools became available (by name-set diff), it emits a ToolsetInfo event to update the TUI immediately. The new tools will be picked up by the next iteration's getTools() call at the top of the loop. reprobe deliberately do
( ctx context.Context, sess *session.Session, a *agent.Agent, currentTools []tools.Tool, sessionSpan trace.Span, events EventSink, )
| 1300 | // reprobe deliberately does NOT return the new tool list: the top-of-loop |
| 1301 | // getTools() is the single authoritative source for agentTools each iteration. |
| 1302 | func (r *LocalRuntime) reprobe( |
| 1303 | ctx context.Context, |
| 1304 | sess *session.Session, |
| 1305 | a *agent.Agent, |
| 1306 | currentTools []tools.Tool, |
| 1307 | sessionSpan trace.Span, |
| 1308 | events EventSink, |
| 1309 | ) { |
| 1310 | updated, err := r.getTools(ctx, a, sessionSpan, events, false) |
| 1311 | if err != nil { |
| 1312 | slog.WarnContext(ctx, "reprobe: getTools failed", "agent", a.Name(), "error", err) |
| 1313 | return |
| 1314 | } |
| 1315 | updated = filterExcludedTools(updated, sess.ExcludedTools) |
| 1316 | updated = r.skillSubSessionTools(ctx, sess, a, updated, events) |
| 1317 | |
| 1318 | // Emit any pending warnings that getTools just generated. |
| 1319 | r.emitAgentWarnings(a, events) |
| 1320 | |
| 1321 | // Compute added tools by comparing name-sets (not just counts), so we |
| 1322 | // correctly handle a toolset that replaced one tool with another. |
| 1323 | prev := make(map[string]struct{}, len(currentTools)) |
| 1324 | for _, t := range currentTools { |
| 1325 | prev[t.Name] = struct{}{} |
| 1326 | } |
| 1327 | var added []string |
| 1328 | for _, t := range updated { |
| 1329 | if _, exists := prev[t.Name]; !exists { |
| 1330 | added = append(added, t.Name) |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | if len(added) == 0 { |
| 1335 | return |
| 1336 | } |
| 1337 | |
| 1338 | slog.InfoContext(ctx, "New tools available after toolset re-probe", |
| 1339 | "agent", a.Name(), "added", added) |
| 1340 | |
| 1341 | // Emit updated tool count to the TUI immediately. |
| 1342 | events.Emit(ToolsetInfo(len(updated), false, a.Name())) |
| 1343 | } |
no test coverage detected