Preserve partial cross-client identity fixes before canonical-ID continuation

This commit is contained in:
2026-10-18 23:28:54 +01:00
parent 980f52bd85
commit d630235657
4 changed files with 46 additions and 44 deletions
+15
View File
@@ -948,6 +948,21 @@ func TestChatHubKeepsMessagesSeparate(t *testing.T) {
}
}
// OpenCode history exposes native message ids but no prompt operation id. The
// broker must therefore leave partial, reordered, older and overlapping pages
// untouched rather than inventing a positional identity mapping.
func TestChatHubHistoryDoesNotInventOperationIdentity(t *testing.T) {
hub := newChatHub()
page := []protocol.ChatMessage{
{ID: "history-y", Role: protocol.ChatRoleUser, OperationID: "provider-value"},
{ID: "history-x", Role: protocol.ChatRoleUser},
}
got := hub.reconcileHistory("ses_1", page)
if len(got) != len(page) || got[0].ID != "history-y" || got[0].OperationID != "provider-value" || got[1].OperationID != "" {
t.Fatalf("history changed without a canonical provider mapping: %+v", got)
}
}
// TestChatHubChargesToolStateBytes pins the retained-state cap: a tool part's
// input/content bytes count against it, and an upsert that would exceed the cap
// is dropped with the overflow diagnostic rather than growing memory.