feat(agent): implement memory consolidation and context management
- Introduced a memory consolidator to summarize older messages when the context window exceeds a specified limit, preserving key facts and tool results. - Enhanced the AgentEngine to utilize the new token estimator and memory consolidator for improved context window management. - Implemented logic to compress message history when approaching token limits, ensuring efficient use of context. - Added unit tests for the memory consolidator and token estimator to validate functionality and performance. - Updated tool execution to validate parameters against JSON schema before execution, improving error handling and robustness.
This commit is contained in:
@@ -102,6 +102,11 @@ func (s *agentService) CreateAgentEngine(
|
||||
// Create tool registry
|
||||
toolRegistry := tools.NewToolRegistry()
|
||||
|
||||
// Apply configurable tool output size limit
|
||||
if config.MaxToolOutputChars > 0 {
|
||||
toolRegistry.SetMaxToolOutputSize(config.MaxToolOutputChars)
|
||||
}
|
||||
|
||||
// Register tools
|
||||
if err := s.registerTools(ctx, toolRegistry, config, rerankModel, chatModel, sessionID); err != nil {
|
||||
return nil, fmt.Errorf("failed to register tools: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user