feat(schema): add CreatedAt field to Message#894
Open
majiayu000 wants to merge 2 commits into
Open
Conversation
Add a CreatedAt *time.Time field to schema.Message to support persisting message timestamps. The field is auto-populated by all constructor functions (UserMessage, AssistantMessage, SystemMessage, ToolMessage) and uses the earliest timestamp when concatenating messages via ConcatMessages. Signed-off-by: majiayu000 <1835304752@qq.com>
…aliasing Copy the time.Time value instead of sharing the pointer with input messages, consistent with how other pointer fields (ResponseMeta, TokenUsage, LogProbs) are handled. Add test asserting pointer independence. Signed-off-by: majiayu000 <1835304752@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #888
Changes
CreatedAt *time.Timefield toMessagestruct withjson:"created_at,omitempty"tag*time.Time(pointer) soomitemptyworks correctly across Go 1.18-1.24CreatedAtin all four constructors:UserMessage(),AssistantMessage(),SystemMessage(),ToolMessage()CreatedAtinConcatMessages: use the earliest non-nil value from input messages (semantically correct for streaming — first chunk represents message creation time)time.Timevalue inConcatMessagesto avoid pointer aliasing (consistent with howResponseMeta/TokenUsageare handled)Note on AgenticMessage
The issue title mentions
schema.AgenticMessagebut this type does not exist in the codebase. Onlyschema.Messageis modified.Test Coverage
CreatedAtclose totime.Now()CreatedAtpresent when set, omitted when nilConcatMessages: earliest timestamp selected, nil values handled, pointer independence verified withNotSame()