Ensure tool execution regardless of long-term memory usage

Modified the `run` method in the Agent class to check and execute tools after generating a response, regardless of whether long-term memory is used or not. This fixes the issue where tools were not being executed when long-term memory was present.

Changes:
- Moved tool execution check and call outside of the long-term memory
  conditional block
- Ensures consistent tool usage across all agent runs
pull/611/head
Sambhav Dixit 6 months ago committed by GitHub
parent fbf65094a6
commit 79ef849de1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -711,20 +711,16 @@ class Agent:
while attempt < self.retry_attempts and not success: while attempt < self.retry_attempts and not success:
try: try:
if self.long_term_memory is not None: if self.long_term_memory is not None:
logger.info( logger.info("Querying long term memory...")
"Querying long term memory..."
)
self.memory_query(task_prompt) self.memory_query(task_prompt)
else: # Generate response using LLM
response_args = ( response = self.llm(task_prompt, *args, **kwargs)
(task_prompt, *args)
if img is None # Check and execute tools
else (task_prompt, img, *args) if self.tools is not None:
) print(f"self.tools is not None: {response}")
response = self.call_llm( self.parse_and_execute_tools(response)
*response_args, **kwargs
)
# Log the step metadata # Log the step metadata
logged = self.log_step_metadata( logged = self.log_step_metadata(

Loading…
Cancel
Save