SetValidated checks that name exists in the team, then sets it as the current agent. Returns the team's lookup error unchanged so callers (e.g. the TUI's switch-agent flow) can propagate the same message.
(name string)
| 53 | // current agent. Returns the team's lookup error unchanged so callers |
| 54 | // (e.g. the TUI's switch-agent flow) can propagate the same message. |
| 55 | func (r *agentRouter) SetValidated(name string) error { |
| 56 | if _, err := r.team.Agent(name); err != nil { |
| 57 | return err |
| 58 | } |
| 59 | r.Set(name) |
| 60 | slog.Debug("Switched current agent", "agent", name) |
| 61 | return nil |
| 62 | } |
| 63 | |
| 64 | // Current returns the current agent. The returned agent is non-nil |
| 65 | // because NewLocalRuntime validates the initial name and Set callers |