chat: reconcile history by canonical message identity
This commit is contained in:
@@ -782,7 +782,7 @@ func TestChatV1ConnectionDrivesThroughCall(t *testing.T) {
|
||||
chat := NewChat(&Connection{Backend: "v1", URL: srv.URL, Directory: "/repo", models: map[string]map[string]string{}, responses: map[string][]byte{}})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if err := chat.Prompt(ctx, "ses_1", "hello"); err != nil {
|
||||
if err := chat.PromptWithMessageID(ctx, "ses_1", "hello", "msg_canonical"); err != nil {
|
||||
t.Fatalf("prompt: %v", err)
|
||||
}
|
||||
if !sawPrompt {
|
||||
@@ -792,6 +792,7 @@ func TestChatV1ConnectionDrivesThroughCall(t *testing.T) {
|
||||
// V2 `parts` shape and the v1 translation has to preserve it, or the native
|
||||
// serve process receives an empty prompt.
|
||||
var sent struct {
|
||||
ID string `json:"id"`
|
||||
Parts []struct {
|
||||
Type string `json:"type"`
|
||||
Text string `json:"text"`
|
||||
@@ -800,7 +801,7 @@ func TestChatV1ConnectionDrivesThroughCall(t *testing.T) {
|
||||
if err := json.Unmarshal([]byte(promptBody), &sent); err != nil {
|
||||
t.Fatalf("prompt body: %v (%s)", err, promptBody)
|
||||
}
|
||||
if len(sent.Parts) != 1 || sent.Parts[0].Type != protocol.ChatPartText || sent.Parts[0].Text != "hello" {
|
||||
if sent.ID != "msg_canonical" || len(sent.Parts) != 1 || sent.Parts[0].Type != protocol.ChatPartText || sent.Parts[0].Text != "hello" {
|
||||
t.Fatalf("prompt text not carried through the v1 translation: %s", promptBody)
|
||||
}
|
||||
var got []protocol.ChatEventFrame
|
||||
|
||||
Reference in New Issue
Block a user