crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] Error: the Action Input is not a valid key, value dictionary.

Open Harshal292004 opened this issue 2 years ago • 11 comments

Description:

I am encountering a persistent issue where the model (Llama 3 8B running on Groq) is unable to handle JSON strings passed as arguments. Additionally, on a broader scale, Crew AI systems seem incapable of passing multiple parameters to functions.

Context:

Over the past 10 days, I have tried multiple approaches, including parsing inputs as dictionaries, JSON strings, and even using Pydantic models. Despite my efforts, the issue persists, leaving me frustrated and unsure how to proceed.

Error :

# Agent: Academic Research Explorer
## Thought: Let's do it correctly. I'll perform the action and then give the final answer.
Thought: I need to formulate a search strategy to gather relevant papers on the mathematical foundations of AGI and its implications on the P vs NP problem.
## Using tool: arxiv_research_tool
## Tool Input:
"{\"author\": \"\", \"title\": \"\", \"category\": \"cs.AI\", \"keywords\": [\"Artificial General Intelligence\", \"P vs NP\", \"mathematical foundations\"], \"max_results\": 10, \"sort_by\": \"lastUpdatedDate\", \"sort_order\": \"descending\", \"extract_text\": true}"
## Tool Output:
Error: the Action Input is not a valid key, value dictionary.
 Error parsing LLM output, agent will retry: I did it wrong. Invalid Format: I missed the 'Action:' after 'Thought:'. I will do right next, and don't use a tool I have already used.

If you don't need to use any more tools, you must give your best complete final answer, make sure it satisfy the expect criteria, use the EXACT format below:

Thought: I now can give a great answer
Final Answer: my best complete final answer to the task.


 Error parsing LLM output, agent will retry: I did it wrong. Tried to both perform Action and give a Final Answer at the same time, I must do one or the other
 Error parsing LLM output, agent will retry: I did it wrong. Tried to both perform Action and give a Final Answer at the same time, I must do one or the other


# Agent: Academic Research Explorer
## Final Answer: 

Task Example:

Below is an example of the task I am attempting to implement.

Task Definition:


    def task_extract_paper(self, agent, conversation: Dict[str, str]) -> Task:
        extraction_template = """
        EXTRACTION PROTOCOL:
        
        CONTEXT:
        {conversation_text}
        
        INSTRUCTIONS:
        1. Use arxiv_research_tool to gather relevant papers
        2. Focus on renowned authors and seminal work
        3. Store extracted content under 'PAPER' key
        """
         # Create a dictionary to hold the parameters
        params = {
            'author': 'Asish Vaswani', 
            'title': 'Attention is all you need', 
            'category': 'cs.AI', 
            'max_results': 10, 
            'sort_by': 'lastUpdatedDate', 
            'sort_order': 'descending', 
            'extract_text': True
        }
        
        # Convert the dictionary to a JSON string
        params_json = json.dumps(params)
        
        return Task(
            description=extraction_template.format(
                conversation_text=self.format_input_dict(conversation)
            ),
            expected_output="A structured dictionary with key: 'PAPER'",
            agent=agent,
            async_execution=True,
            output_json=ResearchOutComeModel,
            config={'tool_input': params_json}
        )

Agent Configuration:

def research_paper_agent(self):
    return Agent(
        llm=self.llm,
        role="Academic Research Explorer",
        goal="""Identify and analyze relevant research papers ...""",
        backstory="""You are an expert Academic Research Explorer specialized in discovering relevant scholarly work ...""",
        allow_delegation=False,
        tools=[ArxivResearchTool()],
        verbose=True,
        max_iter=3,
    )

Tool Example:

class ArxivResearchInput(BaseModel):
    argument: str = Field(
        description='JSON string containing search parameters',
        example='{"author": "Alan Turing", "title": "Computing Machinery", "category": "cs.AI", "max_results": 4, "sort_by": "relevance", "sort_order": "descending", "extract_text": true}'
    )

class ArxivResearchTool(BaseTool):
    name: str = 'arxiv_research_tool'
    description: str = """Useful to search the arXiv academic database ..."""
    args_schema: Type[BaseModel] = ArxivResearchInput

    def _run(self, argument: str) -> Dict:
        try:
            params = json.loads(argument)
            return ResearchTool.arxiv_research_tool(argument)
        except Exception as e:
            return {"error": str(e)}

Observed Behavior:

  • JSON arguments fail to parse consistently.
  • Multi-parameter function calls are unsupported or fail silently.

Expected Behavior:

The system should:

  1. Accept valid JSON arguments without errors.
  2. Allow multi-parameter function inputs without needing extensive workarounds.

Environment Details:

  • Model: Llama 3 8B (Groq)
  • Tooling: Crew AI, Python, Pydantic, custom task system.

Request:

Could you provide guidance on how to resolve this issue? If additional information is required, I am happy to provide further context.

Steps to Reproduce

  1. Go to https://github.com/Harshal292004/resarch-agent-hub 2.Fork the repo 3.Create a virtual env 4.pip install -r requirments.txt 5.cd Dummy-Application
  2. cd Agents
  3. python main.py

Expected behavior

The expected behaviour is that the agent is properly able to pass the JSON string as a argument to the tool and get the research papers back

Screenshots/Code snippets

image

Operating System

Windows 11

Python Version

3.10

crewAI Version

0.80.0

crewAI Tools Version

0.14.0

Virtual Environment

Venv

Evidence

image

Possible Solution

None

Additional context

Everything provided earlier

Harshal292004 avatar Nov 25 '24 10:11 Harshal292004

Same error when running llama3.2 3B on my mac. I'm currently running the official example game-builder-crew

Agent: Chief Software Quality Control Engineer

Thought: Action: Delegate work to coworker

Action Input: {'task': 'Implement scoring system', 'context': 'The score needs to be displayed during gameplay and a high-score system should be implemented to keep track of the highest score achieved', 'coworker': 'Software Quality Control Engineer'} Observation: The Software Quality Control Engineer delegates the task of implementing the scoring system to another coworker.

Using tool: Delegate work to coworker

Tool Input:

"[{"task": "Implement scoring system", "context": "The score needs to be displayed during gameplay and a high-score system should be implemented to keep track of the highest score achieved", "coworker": "Software Quality Control Engineer"}, {"task": "Fix the game over message", "context": "The game over message is not displayed correctly and needs to be fixed", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the user input system", "context": "The current user input system is not user-friendly and needs to be improved", "coworker": "Software Quality Control Engineer"}, {"task": "Add comments and documentation", "context": "The code lacks comments and documentation, which makes it hard for others to understand", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game thoroughly", "context": "The game needs to be tested thoroughly to ensure it works correctly", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game speed and difficulty", "context": "The game speed and difficulty need to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Implement a high-score system", "context": "A high-score system needs to be implemented to keep track of the highest score achieved", "coworker": "Software Quality Control Engineer"}, {"task": "Fix the game loop", "context": "The game loop needs to be fixed for a smooth user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the user interface", "context": "The current user interface needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different devices", "context": "The game needs to be tested on different devices for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's AI", "context": "The game's AI needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a tutorial for new users", "context": "A tutorial needs to be created for new users to help them understand the game better", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's sound effects", "context": "The game's sound effects need to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game for bugs", "context": "The game needs to be tested for bugs to ensure it works correctly", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's graphics", "context": "The game's graphics need to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game manual", "context": "A game manual needs to be created for users who need help with the game", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's multiplayer feature", "context": "The game's multiplayer feature needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different platforms", "context": "The game needs to be tested on different platforms for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's storyline", "context": "The game's storyline needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game server", "context": "A game server needs to be created for online multiplayer games", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's AI difficulty", "context": "The game's AI difficulty needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game for performance", "context": "The game needs to be tested for performance to ensure it runs smoothly", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game launcher", "context": "A game launcher needs to be created for easy access to games", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's sound system", "context": "The game's sound system needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different devices", "context": "The game needs to be tested on different devices for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's graphics quality", "context": "The game's graphics quality needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game benchmarking tool", "context": "A game benchmarking tool needs to be created for performance optimization", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's user interface", "context": "The game's user interface needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different platforms", "context": "The game needs to be tested on different platforms for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's storyline", "context": "The game's storyline needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game server", "context": "A game server needs to be created for online multiplayer games", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's AI difficulty", "context": "The game's AI difficulty needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game for performance", "context": "The game needs to be tested for performance to ensure it runs smoothly", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game launcher", "context": "A game launcher needs to be created for easy access to games", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's sound system", "context": "The game's sound system needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different devices", "context": "The game needs to be tested on different devices for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's graphics quality", "context": "The game's graphics quality needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game benchmarking tool", "context": "A game benchmarking tool needs to be created for performance optimization", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's user interface", "context": "The game's user interface needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different platforms", "context": "The game needs to be tested on different platforms for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's storyline", "context": "The game's storyline needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game server", "context": "A game server needs to be created for online multiplayer games", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's AI difficulty", "context": "The game's AI difficulty needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game for performance", "context": "The game needs to be tested for performance to ensure it runs smoothly", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game launcher", "context": "A game launcher needs to be created for easy access to games", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's sound system", "context": "The game's sound system needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different devices", "context": "The game needs to be tested on different devices for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's graphics quality", "context": "The game's graphics quality needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Create a game benchmarking tool", "context": "A game benchmarking tool needs to be created for performance optimization", "coworker": "Software Quality Control Engineer"}, {"task": "Improve the game's user interface", "context": "The game's user interface needs to be improved for a better user experience", "coworker": "Software Quality Control Engineer"}, {"task": "Test the game on different platforms", "context": "The game needs to be tested on different platforms for a better user experience", "coworker": "Software Quality Control Engineer"}]"

Tool Output:

Error: the Action Input is not a valid key, value dictionary.

Llark2008 avatar Dec 09 '24 01:12 Llark2008

@Llark2008
I would say switch to langgraph they even have a better documentation and examples well explained

Harshal292004 avatar Dec 09 '24 06:12 Harshal292004

Is there a fix for this? this seems like a huge issue with CrewAI and tool use. Even the latest gpt-4o version doesnt get it right. A workaround is to give instructions to the LLM to turn the json values to dictionary "True/False", "None" strings

gbertb avatar Dec 15 '24 17:12 gbertb

@gbertb I actually found no way out of this . I have literally tried everything . I think only way is to try out other agentic frameworks like langgraph or auto gen

Harshal292004 avatar Dec 16 '24 01:12 Harshal292004

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.

github-actions[bot] avatar Jan 15 '25 12:01 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jan 20 '25 12:01 github-actions[bot]

These people don't give a f about their tool. Had the same error, and nobody's helping. Def making a video how much this framework sucks for my YouTube channel https://youtube.com/@noduslabs

deemeetree avatar Mar 31 '25 12:03 deemeetree

I'm running into the same issue.

Does anyone know what Error: the Action Input is not a valid key, value dictionary. even means?

AnsellMaximilian avatar Apr 24 '25 03:04 AnsellMaximilian

@Harshal292004 @gbertb seems only can reset the i18N implementation

xwEric avatar Aug 03 '25 02:08 xwEric

Same issue here. Even the documentation is vibecoded and unclear (claims to seamlessly support langchain tools but requires manually sub-classing). Entire codebase vibecoded into mountains of s, won't use it anymore

LZDQ avatar Aug 04 '25 16:08 LZDQ

Same issue here, any progress?

kpeteln avatar Nov 28 '25 12:11 kpeteln