Skip to content

[Bug]: Runtime logging breaks with MultimodalConversableAgent #3507

@maureen-daum

Description

@maureen-daum

Describe the bug

Enabling Runtime Logging with MultimodalConversableAgent breaks with the following traceback:

Traceback (most recent call last):
  File "/home/mdaum/numbersstation/hive/test_multimodal.py", line 32, in <module>
    user_proxy.initiate_chat(
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 1102, in initiate_chat
    self.send(msg2send, recipient, silent=silent)
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 738, in send
    recipient.receive(message, self, request_reply, silent)
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 902, in receive
    reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 2056, in generate_reply
    final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/agentchat/contrib/multimodal_conversable_agent.py", line 120, in generate_oai_reply
    response = client.create(context=messages[-1].pop("context", None), messages=messages_with_b64_img)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/oai/client.py", line 810, in create
    log_chat_completion(
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/runtime_logging.py", line 85, in log_chat_completion
    autogen_logger.log_chat_completion(
  File "/home/mdaum/.cache/pypoetry/virtualenvs/mlcore--_phYNl_-py3.11/lib/python3.11/site-packages/autogen/logger/file_logger.py", line 102, in log_chat_completion
    source_name = source.name
                  ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'name'

Steps to reproduce

# Ref: https://microsoft.github.io/autogen/docs/notebooks/agentchat_lmm_gpt-4v/
import os

import autogen
from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent
import autogen.runtime_logging


config_list_gpt4 = [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}]

gpt4_llm_config = {"config_list": config_list_gpt4, "cache_seed": 42}

image_agent = MultimodalConversableAgent(
    name="image-explainer",
    max_consecutive_auto_reply=10,
    llm_config=gpt4_llm_config,
)

user_proxy = autogen.UserProxyAgent(
    name="User_proxy",
    system_message="A human admin.",
    human_input_mode="NEVER",  # Try between ALWAYS or NEVER
    max_consecutive_auto_reply=0,
    code_execution_config={
        "use_docker": False
    },  # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.
)

# When this line is not commented out, running this script fails.
autogen.runtime_logging.start(logger_type="file")

# Ask the question with an image
user_proxy.initiate_chat(
    image_agent,
    message="""What's the breed of this dog?
<img https://th.bing.com/th/id/R.422068ce8af4e15b0634fe2540adea7a?rik=y4OcXBE%2fqutDOw&pid=ImgRaw&r=0>.""",
)

Model Used

gpt-4o

Expected Behavior

I expected the same outputs (plus logs) as when runtime logging is not started.

Screenshots and logs

No response

Additional Information

AutoGen version: pyautogen-0.3.0
Python version: 3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.2Issues which are related to the pre 0.4 codebaseneeds-triage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions