Skip to content

Python: unhashable type 'list' exception in function_result_content __hash__ function #9977

Closed

Description

Describe the bug
A TypeError: unhashable type: 'list' exception is raised when invoking the hash function of function_result_content.

To Reproduce
Steps to reproduce the behavior:

  1. Create an agent group chat
  2. Add an agent to the group chat with a kernel function that returns a list
  3. Invoke the agent through the group chat and let the agent invoke the kernel function that returns a list
  4. See error

Expected behavior
no exception if result of function_result_content is of an unhashable type

Platform

  • OS: [Windows]
  • IDE: [VS Code]
  • Language: [Python]
  • Source: [Python SDK 1.17.0]

Additional context

TypeError: unhashable type: 'list'
Traceback (most recent call last):
    async for content in group_chat.invoke():
  File "C:\Source\...\evaluation\.venv\Lib\site-packages\semantic_kernel\agents\group_chat\agent_group_chat.py", line 144, in invoke
    async for message in super().invoke_agent(selected_agent):
  File "C:\Source\....\evaluation\.venv\Lib\site-packages\semantic_kernel\agents\group_chat\agent_chat.py", line 144, in invoke_agent
    async for is_visible, message in channel.invoke(agent):
  File "C:\Source\....\evaluation\.venv\Lib\site-packages\semantic_kernel\agents\channels\chat_history_channel.py", line 75, in invoke
    mutated_history.add(mutated_message)
  File "C:\Source\....\evaluation\.venv\Lib\site-packages\semantic_kernel\contents\chat_message_content.py", line 318, in __hash__
    return hash((self.tag, self.role, self.content, self.encoding, self.finish_reason, *self.items))
  File "C:\Source\....\evaluation\.venv\Lib\site-packages\semantic_kernel\contents\function_result_content.py", line 190, in __hash__
    return hash((self.tag, self.id, self.result, self.name, self.function_name, self.plugin_name, self.encoding))
TypeError: unhashable type: 'list'

Activity

  1. moonbox3 commented on Dec 16, 2024

    @moonbox3
    Collaborator

    Thanks for filing, Bernd Kullick (@berndku). A PR with a fix will be out shortly.

  2. added a commit that references this issue on Dec 16, 2024
    b427208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

PR: ready for reviewAll feedback addressed, ready for reviewsbugSomething isn't workingpythonPull requests for the Python Semantic Kernel

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions