fix(memory): pass temperature, max_tokens and reasoning_effort to memory consolidation
Fix issue #1823: Memory consolidation does not inherit agent temperature and maxTokens configuration. The agent's configured generation parameters were not being passed through to the memory consolidation call, causing it to fall back to default values. This resulted in the consolidation response being truncated before the save_memory tool call was emitted. - Pass temperature, max_tokens, reasoning_effort from AgentLoop to MemoryConsolidator and then to MemoryStore.consolidate() - Forward these parameters to the provider.chat_with_retry() call Fixes #1823
This commit is contained in:
@@ -114,6 +114,9 @@ class AgentLoop:
|
|||||||
context_window_tokens=context_window_tokens,
|
context_window_tokens=context_window_tokens,
|
||||||
build_messages=self.context.build_messages,
|
build_messages=self.context.build_messages,
|
||||||
get_tool_definitions=self.tools.get_definitions,
|
get_tool_definitions=self.tools.get_definitions,
|
||||||
|
temperature=self.temperature,
|
||||||
|
max_tokens=self.max_tokens,
|
||||||
|
reasoning_effort=self.reasoning_effort,
|
||||||
)
|
)
|
||||||
self._register_default_tools()
|
self._register_default_tools()
|
||||||
|
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ class MemoryStore:
|
|||||||
messages: list[dict],
|
messages: list[dict],
|
||||||
provider: LLMProvider,
|
provider: LLMProvider,
|
||||||
model: str,
|
model: str,
|
||||||
|
temperature: float | None = None,
|
||||||
|
max_tokens: int | None = None,
|
||||||
|
reasoning_effort: str | None = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Consolidate the provided message chunk into MEMORY.md + HISTORY.md."""
|
"""Consolidate the provided message chunk into MEMORY.md + HISTORY.md."""
|
||||||
if not messages:
|
if not messages:
|
||||||
@@ -121,6 +124,9 @@ class MemoryStore:
|
|||||||
],
|
],
|
||||||
tools=_SAVE_MEMORY_TOOL,
|
tools=_SAVE_MEMORY_TOOL,
|
||||||
model=model,
|
model=model,
|
||||||
|
temperature=temperature,
|
||||||
|
max_tokens=max_tokens,
|
||||||
|
reasoning_effort=reasoning_effort,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not response.has_tool_calls:
|
if not response.has_tool_calls:
|
||||||
@@ -160,6 +166,9 @@ class MemoryConsolidator:
|
|||||||
context_window_tokens: int,
|
context_window_tokens: int,
|
||||||
build_messages: Callable[..., list[dict[str, Any]]],
|
build_messages: Callable[..., list[dict[str, Any]]],
|
||||||
get_tool_definitions: Callable[[], list[dict[str, Any]]],
|
get_tool_definitions: Callable[[], list[dict[str, Any]]],
|
||||||
|
temperature: float | None = None,
|
||||||
|
max_tokens: int | None = None,
|
||||||
|
reasoning_effort: str | None = None,
|
||||||
):
|
):
|
||||||
self.store = MemoryStore(workspace)
|
self.store = MemoryStore(workspace)
|
||||||
self.provider = provider
|
self.provider = provider
|
||||||
@@ -168,6 +177,9 @@ class MemoryConsolidator:
|
|||||||
self.context_window_tokens = context_window_tokens
|
self.context_window_tokens = context_window_tokens
|
||||||
self._build_messages = build_messages
|
self._build_messages = build_messages
|
||||||
self._get_tool_definitions = get_tool_definitions
|
self._get_tool_definitions = get_tool_definitions
|
||||||
|
self._temperature = temperature
|
||||||
|
self._max_tokens = max_tokens
|
||||||
|
self._reasoning_effort = reasoning_effort
|
||||||
self._locks: weakref.WeakValueDictionary[str, asyncio.Lock] = weakref.WeakValueDictionary()
|
self._locks: weakref.WeakValueDictionary[str, asyncio.Lock] = weakref.WeakValueDictionary()
|
||||||
|
|
||||||
def get_lock(self, session_key: str) -> asyncio.Lock:
|
def get_lock(self, session_key: str) -> asyncio.Lock:
|
||||||
@@ -176,7 +188,14 @@ class MemoryConsolidator:
|
|||||||
|
|
||||||
async def consolidate_messages(self, messages: list[dict[str, object]]) -> bool:
|
async def consolidate_messages(self, messages: list[dict[str, object]]) -> bool:
|
||||||
"""Archive a selected message chunk into persistent memory."""
|
"""Archive a selected message chunk into persistent memory."""
|
||||||
return await self.store.consolidate(messages, self.provider, self.model)
|
return await self.store.consolidate(
|
||||||
|
messages,
|
||||||
|
self.provider,
|
||||||
|
self.model,
|
||||||
|
temperature=self._temperature,
|
||||||
|
max_tokens=self._max_tokens,
|
||||||
|
reasoning_effort=self._reasoning_effort,
|
||||||
|
)
|
||||||
|
|
||||||
def pick_consolidation_boundary(
|
def pick_consolidation_boundary(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in New Issue
Block a user