diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index 29d7037b..49da5987 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -812,6 +812,15 @@ class Agent: *response_args, **kwargs ) + # Check if response is a dictionary and has 'choices' key + if isinstance(response, dict) and 'choices' in response: + response = response['choices'][0]['message']['content'] + elif isinstance(response, str): + # If response is already a string, use it as is + pass + else: + raise ValueError(f"Unexpected response format: {type(response)}") + # Check and execute tools if self.tools is not None: print(f"self.tools is not None: {response}")