diff --git a/coderd/x/chatd/chatd_test.go b/coderd/x/chatd/chatd_test.go index 04833174444..0b8df0a29e5 100644 --- a/coderd/x/chatd/chatd_test.go +++ b/coderd/x/chatd/chatd_test.go @@ -7281,7 +7281,7 @@ func TestActiveServer_CompactionModelOverride(t *testing.T) { OwnerID: user.ID, WorkspaceID: uuid.NullUUID{UUID: ws.ID, Valid: true}, AgentID: uuid.NullUUID{UUID: dbAgent.ID, Valid: true}, - Title: "compaction-override-threshold-lowered", + Title: "compaction-override-added-lower-trigger", ModelConfigID: model.ID, InitialUserContent: []codersdk.ChatMessagePart{ codersdk.ChatMessageText("read the file and continue"), diff --git a/coderd/x/chatd/generation_preparer.go b/coderd/x/chatd/generation_preparer.go index 675fc96f7bf..67d97a8afda 100644 --- a/coderd/x/chatd/generation_preparer.go +++ b/coderd/x/chatd/generation_preparer.go @@ -850,16 +850,12 @@ func (server *Server) prepareGeneration( thresholdPercent: compactionOverrideWindowPercent, contextLimit: resolvedCompactionOverride.Config.ContextLimit, } - // With an unknown window, nothing bounds the history by the - // override's window, so the chat model summarizes instead. - if overrideTrigger.enabled() { - compactionOverride = &resolvedCompactionOverride - otherTrigger = overrideTrigger - bindingSource = bindingCompactionTriggerSource(chatTrigger, overrideTrigger) - if bindingSource == compactionTriggerSourceOrganization { - binding = overrideTrigger - otherTrigger = chatTrigger - } + compactionOverride = &resolvedCompactionOverride + otherTrigger = overrideTrigger + bindingSource = bindingCompactionTriggerSource(chatTrigger, overrideTrigger) + if bindingSource == compactionTriggerSourceOrganization { + binding = overrideTrigger + otherTrigger = chatTrigger } } compactionStepUsage := latestPromptUsage(promptRows) @@ -959,8 +955,9 @@ func latestPromptUsage(messages []database.ChatMessage) fantasy.Usage { return fantasy.Usage{} } -// compactionOverrideWindowPercent leaves room in the override's window for -// the summary prompt and the summary. +// compactionOverrideWindowPercent leaves the rest of the override's window as +// headroom for the summary prompt and summary. It is a target margin, not a +// guarantee: the trigger reads the previous step's prompt usage. const compactionOverrideWindowPercent = int32(80) type compactionTrigger struct {