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:
wizardchen
2026-03-19 22:01:42 +08:00
committed by lyingbug
parent 9f4fb39e10
commit 0851d6d656
13 changed files with 1487 additions and 6 deletions
+9
View File
@@ -43,6 +43,15 @@ type AgentConfig struct {
VLMModelID string `json:"-"` // VLM model ID for tool result image analysis (set from CustomAgent config)
// LLM call timeout in seconds (default: 120). Controls the maximum time for a single LLM call.
LLMCallTimeout int `json:"llm_call_timeout,omitempty"`
// Maximum character length for tool output (default: 16000).
// Outputs exceeding this limit are truncated with head + tail preservation.
MaxToolOutputChars int `json:"max_tool_output_chars,omitempty"`
// Maximum context window tokens for the agent (default: 0 = disabled).
// When set, the agent compresses older messages to stay within this limit,
// preserving tool_call/tool_result pairs.
MaxContextTokens int `json:"max_context_tokens,omitempty"`
}
// SessionAgentConfig represents session-level agent configuration