refactor(event): remove state events #839
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
State events like
ModelLoaded,ToolAdded, andSystemPromptSetwere used incmd/testandcmd/jsonl2mdto show system information in logs. When implementing event storage and resuming functionality (#787), these event will be added to history for every resumption.For example, if we created a new conversation, before this PR, the conversation would have the following events if #787 were merged:
ModelLoadedToolUpdated: read_fileToolUpdated: meta_write_fileSystemPromptSet: You are a helpful assistantPreConversationUserMessage: HelloRequestCompleted: Hi! ...PostConversationThen, if we were resuming such conversation using the
Maria::resumeimplemented in #787, the history will have the following event:ModelLoadedToolUpdated: read_fileToolUpdated: meta_write_fileSystemPromptSet: You are a helpful assistantPreConversationUserMessage: HelloRequestCompleted: Hi! ...PostConversationModelLoadedToolUpdated: read_fileToolUpdated: meta_write_fileSystemPromptSet: You are a helpful assistantWe found out that
ModelLoaded,ToolUpdated, andSystemPromptSetevents are duplicated.Changes
This PR remove the
ModelLoadedandToolUpdatedevent, so that these events does not duplicated when resuming a conversation.In order for
cmd/testandcmd/jsonl2mdto continue to work, we moved these events intocmd/testpackage, by defining type@cmd/test.Eventand@cmd/test.EventDesc