Files
Enterprise-Knowledge-Base/internal/application/service/llmcontext/context_manager_factory.go
T
wizardchen a8924e301e feat(agent): enhance message consolidation and context management
- Improved the message consolidation logic to preserve the current turn's user query and all subsequent assistant/tool messages, ensuring better context retention.
- Updated the CompressContext function to reflect the new consolidation strategy, maintaining the system prompt and relevant recent messages.
- Refactored the context manager to support optional message repository for improved context rebuilding from persistent storage.
- Added comprehensive tests to validate the new consolidation behavior and ensure correct message handling across various scenarios.
2026-03-25 22:08:29 +08:00

19 lines
528 B
Go

package llmcontext
import (
"github.com/Tencent/WeKnora/internal/types/interfaces"
)
// NewContextManagerFromConfig creates a ContextManager.
// messageRepo is optional — when provided, context will be rebuilt from
// the persistent messages table if the cache (Redis/memory) is empty.
func NewContextManagerFromConfig(
storage ContextStorage,
messageRepo interfaces.MessageRepository,
) interfaces.ContextManager {
if storage == nil {
storage = NewMemoryStorage()
}
return NewContextManager(storage, messageRepo)
}