@@ -70,6 +70,8 @@ type Runtime interface {
7070 CurrentAgentCommands (ctx context.Context ) map [string ]string
7171 // CurrentWelcomeMessage returns the welcome message for the active agent
7272 CurrentWelcomeMessage (ctx context.Context ) string
73+ // EmitStartupInfo emits initial agent, team, and toolset information for immediate display
74+ EmitStartupInfo (ctx context.Context , events chan Event )
7375 // RunStream starts the agent's interaction loop and returns a channel of events
7476 RunStream (ctx context.Context , sess * session.Session ) <- chan Event
7577 // Run starts the agent's interaction loop and returns the final messages
@@ -93,6 +95,7 @@ type LocalRuntime struct {
9395 modelsStore modelStore
9496 sessionCompaction bool
9597 managedOAuth bool
98+ startupInfoEmitted bool // Track if startup info has been emitted to avoid unnecessary duplication
9699 elicitationRequestCh chan ElicitationResult // Channel for receiving elicitation responses
97100 elicitationEventsChannel chan Event // Current events channel for sending elicitation requests
98101 elicitationEventsChannelMux sync.RWMutex // Protects elicitationEventsChannel
@@ -196,6 +199,43 @@ func (r *LocalRuntime) CurrentAgent() *agent.Agent {
196199 return current
197200}
198201
202+ // EmitStartupInfo emits initial agent, team, and toolset information for immediate sidebar display
203+ func (r * LocalRuntime ) EmitStartupInfo (ctx context.Context , events chan Event ) {
204+ // Prevent duplicate emissions
205+ if r .startupInfoEmitted {
206+ return
207+ }
208+
209+ a := r .CurrentAgent ()
210+
211+ // Emit agent information for sidebar display
212+ var modelID string
213+ if model := a .Model (); model != nil {
214+ modelID = model .ID ()
215+ }
216+ events <- AgentInfo (a .Name (), modelID , a .Description ())
217+
218+ // Emit team information
219+ availableAgents := r .team .AgentNames ()
220+ events <- TeamInfo (availableAgents , r .currentAgent )
221+
222+ // Emit agent warnings (if any)
223+ r .emitAgentWarnings (a , events )
224+
225+ agentTools , err := a .Tools (ctx )
226+ if err != nil {
227+ slog .Warn ("Failed to get agent tools during startup" , "agent" , a .Name (), "error" , err )
228+ // Emit toolset info with 0 tools if we can't get them
229+ events <- ToolsetInfo (0 , r .currentAgent )
230+ r .startupInfoEmitted = true
231+ return
232+ }
233+
234+ // Emit toolset information
235+ events <- ToolsetInfo (len (agentTools ), r .currentAgent )
236+ r .startupInfoEmitted = true
237+ }
238+
199239// registerDefaultTools registers the default tool handlers
200240func (r * LocalRuntime ) registerDefaultTools () {
201241 slog .Debug ("Registering default tools" )
0 commit comments