fix(agent): include session history in /btw context

This commit is contained in:
lxowalle 2026-04-15 11:39:56 +08:00
parent f0ac4d9b5c
commit 20d8c58ca9
2 changed files with 9 additions and 3 deletions

View file

@ -1555,6 +1555,7 @@ func (al *AgentLoop) askSideQuestion(
var channel, chatID, senderID, senderDisplayName string
var media []string
var activeSkills []string
var history []providers.Message
var summary string
if opts != nil {
channel = opts.Channel
@ -1570,13 +1571,14 @@ func (al *AgentLoop) askSideQuestion(
Budget: agent.ContextWindow,
MaxTokens: agent.MaxTokens,
}); err == nil && resp != nil {
history = resp.History
summary = resp.Summary
}
}
}
messages := agent.ContextBuilder.BuildMessages(
nil,
history,
summary,
question,
media,

View file

@ -286,8 +286,12 @@ func TestProcessMessage_BtwCommandRunsWithoutPersistingHistory(t *testing.T) {
if len(provider.lastMessages) == 0 {
t.Fatal("provider did not receive any messages")
}
if len(provider.lastMessages) != 2 {
t.Fatalf("provider messages len = %d, want 2 (system + user, no history)", len(provider.lastMessages))
if len(provider.lastMessages) != 4 {
t.Fatalf("provider messages len = %d, want 4 (system + prior history + user)", len(provider.lastMessages))
}
if !reflect.DeepEqual(provider.lastMessages[1:3], initialHistory) {
t.Fatalf("provider history = %#v, want %#v", provider.lastMessages[1:3], initialHistory)
}
lastMessage := provider.lastMessages[len(provider.lastMessages)-1]