feat: accept initial prompt#112
Conversation
|
✅ Preview binaries are ready! To test with modules: |
| // Send initial prompt when agent becomes stable for the first time | ||
| if !s.initialPromptSent && convertStatus(currentStatus) == AgentStatusStable { | ||
| if err := s.conversation.SendMessage(FormatMessage(s.agentType, s.initialPrompt)...); err != nil { | ||
| s.logger.Error("Failed to send initial prompt", "error", err) | ||
| } else { | ||
| s.initialPromptSent = true | ||
| currentStatus = st.ConversationStatusChanging | ||
| s.logger.Info("Initial prompt sent successfully") | ||
| } | ||
| } |
There was a problem hiding this comment.
There's an inherent race condition here: we will report "stable" status for a short time period before "changing". Is it possible to prevent this?
There was a problem hiding this comment.
I think line 322 would prevent that:
currentStatus = st.ConversationStatusChanging
There was a problem hiding this comment.
Ah I see now, I assumed that the status updates were done in a separate goroutine but it's actually done in UpdateStatusAndEmitChanges() below in line 326.
I think it's worth adding a test for this behaviour so that we can validate that we don't send an extraneous status update.
I also think this logic might be better encapsulated inside the Conversation.
johnstcn
left a comment
There was a problem hiding this comment.
Can we add tests for this new functionality?
| // Send initial prompt when agent becomes stable for the first time | ||
| if !s.initialPromptSent && convertStatus(currentStatus) == AgentStatusStable { | ||
| if err := s.conversation.SendMessage(FormatMessage(s.agentType, s.initialPrompt)...); err != nil { | ||
| s.logger.Error("Failed to send initial prompt", "error", err) | ||
| } else { | ||
| s.initialPromptSent = true | ||
| currentStatus = st.ConversationStatusChanging | ||
| s.logger.Info("Initial prompt sent successfully") | ||
| } | ||
| } |
There was a problem hiding this comment.
Ah I see now, I assumed that the status updates were done in a separate goroutine but it's actually done in UpdateStatusAndEmitChanges() below in line 326.
I think it's worth adding a test for this behaviour so that we can validate that we don't send an extraneous status update.
I also think this logic might be better encapsulated inside the Conversation.
|
✅ Preview binaries are ready! To test with modules: |
Done
+1, I'm confused on how to test this. |
|
Approving so we can get this released for the copilot-cli module release |
With the current implementation, I think you'd need to test the |
Created a separate issue to track this #114 |
Closes #111
Usage example
agentapi server -I="Hello World" --term-width 76 --term-height 1190 -- copilot