This commit is contained in:
afjcjsbx 2026-05-23 09:42:56 +02:00
parent 6a97b1b087
commit 9bb44b0a80
2 changed files with 8 additions and 16 deletions

View file

@ -71,7 +71,14 @@ func (p *Pipeline) SetupTurn(ctx context.Context, ts *turnState) (*turnExecution
history, messages, fit = trimHistoryToFitContextWindow(
history,
func(trimmedHistory []providers.Message) []providers.Message {
rebuildPromptReq := promptBuildRequestForTurn(ts, trimmedHistory, summary, ts.userMessage, ts.media, cfg)
rebuildPromptReq := promptBuildRequestForTurn(
ts,
trimmedHistory,
summary,
ts.userMessage,
ts.media,
cfg,
)
rebuildPromptReq.ActiveSkills = append([]string(nil), contextualSkills...)
rebuilt := ts.agent.ContextBuilder.BuildMessagesFromPrompt(rebuildPromptReq)
return resolveMediaRefs(rebuilt, p.MediaStore, maxMediaSize)

View file

@ -690,21 +690,6 @@ func (ts *turnState) restoreSession(agent *AgentInstance) error {
return agent.Sessions.Save(ts.sessionKey)
}
// messagesContentEqual compares two message slices by content only, ignoring CreatedAt.
// JSON roundtrip loses the monotonic clock portion of time.Time, so direct
// reflect.DeepEqual would always differ on messages that roundtripped through
// the JSONL store.
func messagesContentEqual(a, b []providers.Message) bool {
for i := range a {
aCopy, bCopy := a[i], b[i]
aCopy.CreatedAt, bCopy.CreatedAt = nil, nil
if !reflect.DeepEqual(aCopy, bCopy) {
return false
}
}
return true
}
func matchingTurnMessageTail(history, persisted []providers.Message) int {
maxMatch := min(len(history), len(persisted))
for size := maxMatch; size > 0; size-- {