@@ -29,19 +29,17 @@ import (
29
29
30
30
// Server represents the HTTP server
31
31
type Server struct {
32
- router chi.Router
33
- api huma.API
34
- port int
35
- srv * http.Server
36
- mu sync.RWMutex
37
- logger * slog.Logger
38
- conversation * st.Conversation
39
- agentio * termexec.Process
40
- agentType mf.AgentType
41
- emitter * EventEmitter
42
- chatBasePath string
43
- initialPrompt string
44
- initialPromptSent bool
32
+ router chi.Router
33
+ api huma.API
34
+ port int
35
+ srv * http.Server
36
+ mu sync.RWMutex
37
+ logger * slog.Logger
38
+ conversation * st.Conversation
39
+ agentio * termexec.Process
40
+ agentType mf.AgentType
41
+ emitter * EventEmitter
42
+ chatBasePath string
45
43
}
46
44
47
45
func (s * Server ) NormalizeSchema (schema any ) any {
@@ -233,20 +231,18 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) {
233
231
SnapshotInterval : snapshotInterval ,
234
232
ScreenStabilityLength : 2 * time .Second ,
235
233
FormatMessage : formatMessage ,
236
- })
234
+ }, config . InitialPrompt )
237
235
emitter := NewEventEmitter (1024 )
238
236
s := & Server {
239
- router : router ,
240
- api : api ,
241
- port : config .Port ,
242
- conversation : conversation ,
243
- logger : logger ,
244
- agentio : config .Process ,
245
- agentType : config .AgentType ,
246
- emitter : emitter ,
247
- chatBasePath : strings .TrimSuffix (config .ChatBasePath , "/" ),
248
- initialPrompt : config .InitialPrompt ,
249
- initialPromptSent : len (config .InitialPrompt ) == 0 ,
237
+ router : router ,
238
+ api : api ,
239
+ port : config .Port ,
240
+ conversation : conversation ,
241
+ logger : logger ,
242
+ agentio : config .Process ,
243
+ agentType : config .AgentType ,
244
+ emitter : emitter ,
245
+ chatBasePath : strings .TrimSuffix (config .ChatBasePath , "/" ),
250
246
}
251
247
252
248
// Register API routes
@@ -314,11 +310,11 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) {
314
310
currentStatus := s .conversation .Status ()
315
311
316
312
// Send initial prompt when agent becomes stable for the first time
317
- if ! s .initialPromptSent && convertStatus (currentStatus ) == AgentStatusStable {
318
- if err := s .conversation .SendMessage (FormatMessage (s .agentType , s .initialPrompt )... ); err != nil {
313
+ if ! s .conversation . InitialPromptSent && convertStatus (currentStatus ) == AgentStatusStable {
314
+ if err := s .conversation .SendMessage (FormatMessage (s .agentType , s .conversation . InitialPrompt )... ); err != nil {
319
315
s .logger .Error ("Failed to send initial prompt" , "error" , err )
320
316
} else {
321
- s .initialPromptSent = true
317
+ s .conversation . InitialPromptSent = true
322
318
currentStatus = st .ConversationStatusChanging
323
319
s .logger .Info ("Initial prompt sent successfully" )
324
320
}
0 commit comments