Skip to content

duplicate response when using litellm with memory #612

@MervinPraison

Description

@MervinPraison

The Task and Response are getting printed twice. Identify the issue and fix it with minimal code changes

❯ python memory1.py
22:27:18 - LiteLLM:DEBUG: http_handler.py:530 - Using AiohttpTransport...
[22:27:18] DEBUG    [22:27:18] http_handler.py:530 DEBUG Using        http_handler.py:530
                    AiohttpTransport...                                                  
22:27:18 - LiteLLM:DEBUG: http_handler.py:554 - Creating AiohttpTransport...
           DEBUG    [22:27:18] http_handler.py:554 DEBUG Creating     http_handler.py:554
                    AiohttpTransport...                                                  
22:27:18 - LiteLLM:DEBUG: http_handler.py:530 - Using AiohttpTransport...
           DEBUG    [22:27:18] http_handler.py:530 DEBUG Using        http_handler.py:530
                    AiohttpTransport...                                                  
22:27:18 - LiteLLM:DEBUG: http_handler.py:554 - Creating AiohttpTransport...
           DEBUG    [22:27:18] http_handler.py:554 DEBUG Creating     http_handler.py:554
                    AiohttpTransport...                                                  
22:27:18 - LiteLLM:DEBUG: litellm_logging.py:169 - [Non-Blocking] Unable to import GenericAPILogger - LiteLLM Enterprise Feature - No module named 'litellm_enterprise'
           DEBUG    [22:27:18] litellm_logging.py:169 DEBUG        litellm_logging.py:169
                    [Non-Blocking] Unable to import                                      
                    GenericAPILogger - LiteLLM Enterprise Feature                        
                    - No module named 'litellm_enterprise'                               
22:27:18 - LiteLLM:DEBUG: transformation.py:17 - [Non-Blocking] Unable to import _ENTERPRISE_ResponsesSessionHandler - LiteLLM Enterprise Feature - No module named 'litellm_enterprise'
           DEBUG    [22:27:18] transformation.py:17 DEBUG            transformation.py:17
                    [Non-Blocking] Unable to import                                      
                    _ENTERPRISE_ResponsesSessionHandler - LiteLLM                        
                    Enterprise Feature - No module named                                 
                    'litellm_enterprise'                                                 
22:27:18 - LiteLLM:DEBUG: http_handler.py:530 - Using AiohttpTransport...
           DEBUG    [22:27:18] http_handler.py:530 DEBUG Using        http_handler.py:530
                    AiohttpTransport...                                                  
22:27:18 - LiteLLM:DEBUG: http_handler.py:554 - Creating AiohttpTransport...
           DEBUG    [22:27:18] http_handler.py:554 DEBUG Creating     http_handler.py:554
                    AiohttpTransport...                                                  
22:27:18 - LiteLLM:DEBUG: http_handler.py:530 - Using AiohttpTransport...
           DEBUG    [22:27:18] http_handler.py:530 DEBUG Using        http_handler.py:530
                    AiohttpTransport...                                                  
22:27:18 - LiteLLM:DEBUG: http_handler.py:554 - Creating AiohttpTransport...
           DEBUG    [22:27:18] http_handler.py:554 DEBUG Creating     http_handler.py:554
                    AiohttpTransport...                                                  
[22:27:19] DEBUG    [22:27:19] process.py:21 DEBUG === Initializing Process process.py:21
                    ===                                                                  
           DEBUG    [22:27:19] process.py:22 DEBUG Number of tasks: 1       process.py:22
           DEBUG    [22:27:19] process.py:23 DEBUG Number of agents: 1      process.py:23
           DEBUG    [22:27:19] process.py:24 DEBUG Manager LLM: gpt-4o      process.py:24
           DEBUG    [22:27:19] process.py:25 DEBUG Verbose mode: 0          process.py:25
           DEBUG    [22:27:19] process.py:26 DEBUG Max iterations: 10       process.py:26
[22:27:20] DEBUG    [22:27:20] agent.py:1050 DEBUG Agent.chat parameters: { agent.py:1050
                      "prompt": "\nYou need to do the following task: Write              
                    a blog post about AI trends in 1 paragraph.\nExpected                
                    Outpu...",                                                           
                      "temperature": 0.2,                                                
                      "tools": null,                                                     
                      "output_json": null,                                               
                      "output_pydantic": null,                                           
                      "reasoning_steps": false,                                          
                      "agent_name": "Agent",                                             
                      "agent_role": "Blog Writer",                                       
                      "agent_goal": "Write a blog post about AI"                         
                    }                                                                    
           INFO     [22:27:20] llm.py:296 INFO Getting response from           llm.py:296
                    openai/gpt-4o-mini                                                   
           DEBUG    [22:27:20] llm.py:324 DEBUG LLM instance configuration: {  llm.py:324
                      "model": "openai/gpt-4o-mini",                                     
                      "timeout": null,                                                   
                      "temperature": 0.7,                                                
                      "top_p": null,                                                     
                      "n": null,                                                         
                      "max_tokens": 2000,                                                
                      "presence_penalty": null,                                          
                      "frequency_penalty": null,                                         
                      "logit_bias": null,                                                
                      "response_format": null,                                           
                      "seed": null,                                                      
                      "logprobs": null,                                                  
                      "top_logprobs": null,                                              
                      "api_version": null,                                               
                      "stop_phrases": null,                                              
                      "api_key": "***",                                                  
                      "base_url": null,                                                  
                      "verbose": true,                                                   
                      "markdown": true,                                                  
                      "self_reflect": false,                                             
                      "max_reflect": 3,                                                  
                      "min_reflect": 1,                                                  
                      "reasoning_steps": false                                           
                    }                                                                    
           DEBUG    [22:27:20] llm.py:345 DEBUG get_response parameters: {     llm.py:345
                      "prompt": "\nYou need to do the following task: Write a            
                    blog post about AI trends in 1 paragraph.\nExpected                  
                    Outpu...",                                                           
                      "system_prompt": "Expert at writing blog posts\n\nYour             
                    Role: Blog Writer\n\nYour Goal: Write a blog post about              
                    AI",                                                                 
                      "chat_history": null,                                              
                      "temperature": 0.2,                                                
                      "tools": null,                                                     
                      "output_json": null,                                               
                      "output_pydantic": null,                                           
                      "verbose": true,                                                   
                      "markdown": true,                                                  
                      "self_reflect": false,                                             
                      "max_reflect": 3,                                                  
                      "min_reflect": 1,                                                  
                      "agent_name": "Agent",                                             
                      "agent_role": "Blog Writer",                                       
                      "agent_tools": [],                                                 
                      "kwargs": "{'reasoning_steps': False}"                             
                    }                                                                    
╭─ Agent Info ──────────────────────────────────────────────────────────────────────────╮
│                                                                                       │
│  👤 Agent: Agent                                                                      │
│  Role: Blog Writer                                                                    │
│                                                                                       │
╰───────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────── Instruction ─────────────────────────────────────╮
│ Agent Agent is processing prompt:                                                     │
│ You need to do the following task: Write a blog post about AI trends in 1 paragraph.  │
│ Expected Output: Well-written blog post about AI trends.                              │
│                                                                                       │
│                                                                                       │
│ Relevant memory context:                                                              │
│ Short-term Memory Context                                                             │
│ =========================                                                             │
│                                                                                       │
│  • As we move further into 2024, several key trends in artificial intelligence are    │
│ shaping the landscape of technology and business. One of the most...                  │
│                                                                                       │
│ Long-term Memory Context                                                              │
│ ========================                                                              │
│                                                                                       │
│  • As we move further into 2024, several key trends in artificial intelligence are    │
│ shaping the landscape of technology and business. One of the most significant trends  │
│ is the rise of generative AI, which is revolutionizing content creation across        │
│ various mediums, from text and images to music and video, thereby enhancing           │
│ creativity and efficiency for businesses. Additionally, the focus on AI ethics and    │
│ governance is intensifying, with organizations prioritizing responsible practices to  │
│ mitigate bias and ensure transparency in AI applications. The integration of AI with  │
│ edge computing is also gaining traction, facilitating real-time data processing and   │
│ decision-making at the source, particularly beneficial for IoT applications.          │
│ Furthermore, advancements in natural language processing are making AI more           │
│ conversational and accessible, leading to improved customer interactions and support  │
│ systems. As these trends continue to evolve, they promise to redefine industries and  │
│ enhance the way we live and work. (Memory record: As we move further into 2024,       │
│ several key trends in artificial intelligence are shaping the landscape of technology │
│ and business. One of the most significant trends is the rise of generative AI, which  │
│ is revolutionizing content creation across various mediums, from text and images to   │
│ music and video, thereby enhancing creativity and efficiency for businesses.          │
│ Additionally, the focus on AI ethics and governance is intensifying, with             │
│ organizations prioritizing responsible practices to mitigate bias and ensure          │
│ transparency in AI applications. The integration of AI with edge computing is also    │
│ gaining traction, facilitating real-time data processing and decision-making at the   │
│ source, particularly beneficial for IoT applications. Furthermore, advancements in    │
│ natural language processing are making AI more conversational and accessible, leading │
│ to improved customer interactions and support systems. As these trends continue to    │
│ evolve, they promise to redefine industries and enhance the way we live and           │
│ work.)Please provide only the final result of your work. Do not add any conversation  │
│ or extra explanation.                                                                 │
╰───────────────────────────────────────────────────────────────────────────────────────╯
           DEBUG    [22:27:20] main.py:224 DEBUG Empty content in             main.py:224
                    display_generating, returning early                                  
╭───────────────────────────────── Generating... 2.8s ──────────────────────────────────╮
│ As we move further into 2024, several key trends in artificial intelligence are       │
│ shaping the landscape of technology and business. One of the most significant trends  │
│ is the rise of generative AI, which is revolutionizing content creation across        │
│ various mediums, from text and images to music and video, thereby enhancing           │
│ creativity and efficiency for businesses. Additionally, the focus on AI ethics and    │
│ governance is intensifying, with organizations prioritizing responsible practices to  │
│ mitigate bias and ensure transparency in AI applications. The integration of AI with  │
│ edge computing is also gaining traction, facilitating real-time data processing and   │
│ decision-making at the source, particularly beneficial for IoT applications.          │
│ Furthermore, advancements in natural language processing are making AI more           │
│ conversational and accessible, leading to improved customer interactions and support  │
│ systems. As these trends continue to evolve, they promise to redefine industries and  │
│ enhance the way we live and work.                                                     │
╰───────────────────────────────────────────────────────────────────────────────────────╯
Response generated in 5.4s
╭──────────────────────────────────────── Task ─────────────────────────────────────────╮
│ You need to do the following task: Write a blog post about AI trends in 1 paragraph.  │
│ Expected Output: Well-written blog post about AI trends.                              │
│                                                                                       │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │
│ ┃                Relevant memory context: Short-term Memory Context                 ┃ │
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │
│                                                                                       │
│ • As we move further into 2024, several key trends in artificial intelligence are     │
│ shaping the landscape of technology and business. One of the most...                  │
│                                                                                       │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │
│ ┃                             Long-term Memory Context                              ┃ │
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │
│                                                                                       │
│ • As we move further into 2024, several key trends in artificial intelligence are     │
│ shaping the landscape of technology and business. One of the most significant trends  │
│ is the rise of generative AI, which is revolutionizing content creation across        │
│ various mediums, from text and images to music and video, thereby enhancing           │
│ creativity and efficiency for businesses. Additionally, the focus on AI ethics and    │
│ governance is intensifying, with organizations prioritizing responsible practices to  │
│ mitigate bias and ensure transparency in AI applications. The integration of AI with  │
│ edge computing is also gaining traction, facilitating real-time data processing and   │
│ decision-making at the source, particularly beneficial for IoT applications.          │
│ Furthermore, advancements in natural language processing are making AI more           │
│ conversational and accessible, leading to improved customer interactions and support  │
│ systems. As these trends continue to evolve, they promise to redefine industries and  │
│ enhance the way we live and work. (Memory record: As we move further into 2024,       │
│ several key trends in artificial intelligence are shaping the landscape of technology │
│ and business. One of the most significant trends is the rise of generative AI, which  │
│ is revolutionizing content creation across various mediums, from text and images to   │
│ music and video, thereby enhancing creativity and efficiency for businesses.          │
│ Additionally, the focus on AI ethics and governance is intensifying, with             │
│ organizations prioritizing responsible practices to mitigate bias and ensure          │
│ transparency in AI applications. The integration of AI with edge computing is also    │
│ gaining traction, facilitating real-time data processing and decision-making at the   │
│ source, particularly beneficial for IoT applications. Furthermore, advancements in    │
│ natural language processing are making AI more conversational and accessible, leading │
│ to improved customer interactions and support systems. As these trends continue to    │
│ evolve, they promise to redefine industries and enhance the way we live and           │
│ work.)Please provide only the final result of your work. Do not add any conversation  │
│ or extra explanation.                                                                 │
╰───────────────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────── Response ───────────────────────────────────────╮
│ As we move further into 2024, several key trends in artificial intelligence are       │
│ shaping the landscape of technology and business. One of the most significant trends  │
│ is the rise of generative AI, which is revolutionizing content creation across        │
│ various mediums, from text and images to music and video, thereby enhancing           │
│ creativity and efficiency for businesses. Additionally, the focus on AI ethics and    │
│ governance is intensifying, with organizations prioritizing responsible practices to  │
│ mitigate bias and ensure transparency in AI applications. The integration of AI with  │
│ edge computing is also gaining traction, facilitating real-time data processing and   │
│ decision-making at the source, particularly beneficial for IoT applications.          │
│ Furthermore, advancements in natural language processing are making AI more           │
│ conversational and accessible, leading to improved customer interactions and support  │
│ systems. As these trends continue to evolve, they promise to redefine industries and  │
│ enhance the way we live and work.                                                     │
╰───────────────────────────────────────────────────────────────────────────────────────╯
Response generated in 5.4s
╭──────────────────────────────────────── Task ─────────────────────────────────────────╮
│ You need to do the following task: Write a blog post about AI trends in 1 paragraph.  │
│ Expected Output: Well-written blog post about AI trends.                              │
│                                                                                       │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │
│ ┃                Relevant memory context: Short-term Memory Context                 ┃ │
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │
│                                                                                       │
│ • As we move further into 2024, several key trends in artificial intelligence are     │
│ shaping the landscape of technology and business. One of the most...                  │
│                                                                                       │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │
│ ┃                             Long-term Memory Context                              ┃ │
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │
│                                                                                       │
│ • As we move further into 2024, several key trends in artificial intelligence are     │
│ shaping the landscape of technology and business. One of the most significant trends  │
│ is the rise of generative AI, which is revolutionizing content creation across        │
│ various mediums, from text and images to music and video, thereby enhancing           │
│ creativity and efficiency for businesses. Additionally, the focus on AI ethics and    │
│ governance is intensifying, with organizations prioritizing responsible practices to  │
│ mitigate bias and ensure transparency in AI applications. The integration of AI with  │
│ edge computing is also gaining traction, facilitating real-time data processing and   │
│ decision-making at the source, particularly beneficial for IoT applications.          │
│ Furthermore, advancements in natural language processing are making AI more           │
│ conversational and accessible, leading to improved customer interactions and support  │
│ systems. As these trends continue to evolve, they promise to redefine industries and  │
│ enhance the way we live and work. (Memory record: As we move further into 2024,       │
│ several key trends in artificial intelligence are shaping the landscape of technology │
│ and business. One of the most significant trends is the rise of generative AI, which  │
│ is revolutionizing content creation across various mediums, from text and images to   │
│ music and video, thereby enhancing creativity and efficiency for businesses.          │
│ Additionally, the focus on AI ethics and governance is intensifying, with             │
│ organizations prioritizing responsible practices to mitigate bias and ensure          │
│ transparency in AI applications. The integration of AI with edge computing is also    │
│ gaining traction, facilitating real-time data processing and decision-making at the   │
│ source, particularly beneficial for IoT applications. Furthermore, advancements in    │
│ natural language processing are making AI more conversational and accessible, leading │
│ to improved customer interactions and support systems. As these trends continue to    │
│ evolve, they promise to redefine industries and enhance the way we live and           │
│ work.)Please provide only the final result of your work. Do not add any conversation  │
│ or extra explanation.                                                                 │
╰───────────────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────── Response ───────────────────────────────────────╮
│ As we move further into 2024, several key trends in artificial intelligence are       │
│ shaping the landscape of technology and business. One of the most significant trends  │
│ is the rise of generative AI, which is revolutionizing content creation across        │
│ various mediums, from text and images to music and video, thereby enhancing           │
│ creativity and efficiency for businesses. Additionally, the focus on AI ethics and    │
│ governance is intensifying, with organizations prioritizing responsible practices to  │
│ mitigate bias and ensure transparency in AI applications. The integration of AI with  │
│ edge computing is also gaining traction, facilitating real-time data processing and   │
│ decision-making at the source, particularly beneficial for IoT applications.          │
│ Furthermore, advancements in natural language processing are making AI more           │
│ conversational and accessible, leading to improved customer interactions and support  │
│ systems. As these trends continue to evolve, they promise to redefine industries and  │
│ enhance the way we live and work.                                                     │
╰───────────────────────────────────────────────────────────────────────────────────────╯
[22:27:25] DEBUG    [22:27:25] agent.py:1120 DEBUG Agent.chat completed in  agent.py:1120
                    5.39 seconds                                                    
❯ 



 output showed above , its using llm.py when using litellm 

litellm or llm_config 

Code below

from praisonaiagents import Agent, Task, PraisonAIAgents
import os
from dotenv import load_dotenv

load_dotenv()

llm_config = {
    "model": "openai/gpt-4o-mini",
    "api_key": os.getenv('OPENAI_API_KEY'),
    "temperature": 0.7,
    "max_tokens": 2000
}

blog_agent = Agent(
    role="Blog Writer",
    goal="Write a blog post about AI",
    backstory="Expert at writing blog posts",
    llm=llm_config,
)

blog_task = Task(
    description="Write a blog post about AI trends in 1 paragraph",
    expected_output="Well-written blog post about AI trends",
    agent=blog_agent
)

agents = PraisonAIAgents(
    agents=[blog_agent],
    tasks=[blog_task],
    memory=True
)

result = agents.start()



Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions