[BUG] TypeError: unhashable type: 'dict' in Delegate Tool
Description
TypeError: unhashable type: 'dict'
Traceback:
in crewai\task.py(320)increment_delegations() https://github.com/crewAIInc/crewAI/blob/627b9f1abb3de753d8b2e097c3baaf1d90d473d3/src/crewai/task.py#L320
in crewai\tools\tool_usage.py(159)_use() https://github.com/crewAIInc/crewAI/blob/627b9f1abb3de753d8b2e097c3baaf1d90d473d3/src/crewai/tools/tool_usage.py#L155
coworker here is not a string. It is a dict like that: {'description': 'Chief Technology Officer (CTO)', 'type': 'str'}. I don't know why.
Can you help ?
Steps to Reproduce
Create 2 agents, one should be able to delegate to the other. Create 1 task.
Expected behavior
No error
Screenshots/Code snippets
.
Operating System
Windows 11
Python Version
3.12
crewAI Version
0.86.0
crewAI Tools Version
0.17.0
Virtual Environment
Venv
Evidence
I encountered an error while trying to use the tool. This was the error: unhashable type: 'dict'.
Tool Delegate work to coworker accepts these inputs: Tool Name: Delegate work to coworker
Tool Arguments: {'task': {'description': 'The task to delegate', 'type': 'str'}, 'context': {'description': 'The context for the task', 'type': 'str'}, 'coworker': {'description': 'The role/name of the coworker to delegate to', 'type': 'str'}}
Possible Solution
I don't know how the coworkers are found.
What is calling.arguments.get("coworker")?
Additional context
.
@antoinedelplace got any solution for the issue, i think we need to provide the context of one agent to other agent in form the some structure , so that the second agent will know what to do when the delegation occurs.
I have checked everywhere but I cannot find the context or the structure I need to give. I still think there is a bug that needs to be fixed.
Here is another test I made :
-
I tried to run the crew given in the example here (that uses delegation): https://github.com/crewAIInc/crewAI-examples/tree/main/game-builder-crew. Everything works fine.
-
Now I want to make it a bit more challenging with the delegation. I am just changing the agent responsible for the code generation : Instead of
agent=self.senior_engineer_agent()(https://github.com/crewAIInc/crewAI-examples/blob/fe723eaeb96597da62f15d791838b3b43770d596/game-builder-crew/src/game_builder_crew/crew.py#L37), I wantagent=self.chief_qa_engineer_agent() -
I then expect that this "chief" delegates the code creation to the software engineer. That's what the verbose is telling me :
# Agent: Chief Software Quality Control Engineer
## Thought: I will delegate this task to a Senior Software Engineer, as they likely have more experience with game development in Python.
## Using tool: Delegate work to coworker
## Tool Input:
"{\"task\": {\"description\": \"Create a Snake Game using Python\", \"type\": \"str\"}, \"context\": {\"description\": \"The game mechanics involve the snake moving, growing upon eating food, and ending if it collides with itself or the game area boundaries.\"}, \"coworker\": {\"description\": \"Senior Software Engineer\", \"type\": \"str\"}}"
## Tool Output:
I encountered an error while trying to use the tool. This was the error: unhashable type: 'dict'.
Tool Delegate work to coworker accepts these inputs: Tool Name: Delegate work to coworker
Tool Arguments: {'task': {'description': 'The task to delegate', 'type': 'str'}, 'context': {'description': 'The context for the task', 'type': 'str'}, 'coworker': {'description': 'The role/name of the coworker to delegate to', 'type': 'str'}}
Tool Description: Delegate a specific task to one of the following coworkers: Software Quality Control Engineer
, Senior Software Engineer
The input to this tool should be the coworker, the task you want them to do, and ALL necessary context to execute the task, they know nothing about the task, so share absolute everything you know, don't reference things but instead explain them..
Moving on then. I MUST either use a tool (use one at time) OR give my best final answer not both at the same time. To Use the following format:
Thought: you should always think about what to do
Action: the action to take, should be one of [Delegate work to coworker, Ask question to coworker]
Action Input: the input to the action, dictionary enclosed in curly braces
Observation: the result of the action
... (this Thought/Action/Action Input/Result can repeat N times)
Thought: I now can give a great answer
Final Answer: Your final answer must be the great and the most complete as possible, it must be outcome described
so here , there is one more doubt is that an agent is doing a task and got some output, and that output is used by another agent which is follow up , so the output is not accessible for now , i checked it, so we get this somehow there might a connection.
https://github.com/crewAIInc/crewAI/issues/1793
@antoinedelplace once have a look at this, may solve this error , not sure.
I am having the same issue when trying to do a hierarchal process with a manager agent and a coworker, using llama 3.3.
I found the issue where the LLM is using the tool arg definitions and putting a dict in a dict for the Action Input.
My workaround is to change this in the en.json under translations.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using \" to wrap keys and values that doesn't have nested json objects. Only use the type as how to format the input.
@antoinedelplace
Same error here.
@fsa317 did u found any solution for that ??
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Did you find any solution for that?
Had the same error
class BrowserTool(BaseTool):
name: str = "Scrape reddit content"
description: str = "Useful to scrape a reddit content"
def _run(self, query: str) -> str:
"""Run the tool."""
return self.scrape_reddit()
changed the query argument type to dict worked like magic
class BrowserTool(BaseTool):
name: str = "Scrape reddit content"
description: str = "Useful to scrape a reddit content"
def _run(self, query: dict) -> str:
"""Run the tool."""
return self.scrape_reddit()
Same here, my solution: just change the llm to smarter one
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
The issue persists, not sure what the resolution is
I encountered an error while trying to use the tool. This was the error: unhashable type: 'dict'. │
│ Tool Delegate work to coworker accepts these inputs: Tool Name: Delegate work to coworker │
│ Tool Arguments: {'task': {'description': 'The task to delegate', 'type': 'str'}, 'context': {'description': 'The context for the task', 'type': 'str'}, 'coworker': {'description': 'The role/name of the │
│ coworker to delegate to', 'type': 'str'}}