crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Persistent error when attempting to use tool with the correct input format

Open P7201 opened this issue 9 months ago • 9 comments

The final agent and tool in my crew is having an issue where it will not accept the input from its preceding crew member. The input is coming in as a JSON object and seems to be formatted properly but the tool will not accept it. Here is the Output:

Action Input:

{
  "coworker": "Expert Query Analyzer and Classifier",
  "question": "I am encountering a persistent error when attempting to use the Document_Synthesis tool with the correct input format. The error states that the Action 
Input is not a valid key, value dictionary, despite the format appearing correct. Can you help me understand why this error is occurring and how to resolve it?",      
  "context": "I am trying to synthesize information from a document titled 'The_role_of_human_factors_in_aviation_ground_operation_related_accidents.pdf' using the Document_Synthesis tool. The input provided is a JSON dictionary with the query and the document details, which is the expected format for the tool. However, the tool is 
returning an error message stating that the input is not valid. Here is the input I have been using: {\"query\": \"What are some common variables used in studies regarding human error-based aviation accidents\", \"documents\": [{\"title\": \"The_role_of_human_factors_in_aviation_ground_operation_related_accidents.pdf\", \"path\": \"C:/Users/Admin/Desktop/erdcDBFunc/crewAIDocSum/documents/The_role_of_human_factors_in_aviation_ground_operation_related_accidents.pdf\"}]}"
}

Final Answer:

I apologize for the inconvenience, but due to a persistent error with the tools provided, I am unable to access the document and synthesize the information required to answer the query regarding common variables used in studies of human error-based aviation accidents. My goal was to provide a detailed synthesis report that addressed the query comprehensively, but without the ability to analyze the document, I cannot fulfill this task. If you have any further questions or need assistance with a different query, please let me know, and I will do my best to assist you.

P7201 avatar May 01 '24 17:05 P7201

Oh that is an interesting one, can you share more of the logs so we can debug a little further?

joaomdmoura avatar May 01 '24 18:05 joaomdmoura

Yes, I have made a few changes to the tools, and tasks assigned to the various agents. I can share the tools and tasks files and the full output of the thought process.

P7201 avatar May 02 '24 02:05 P7201

The problem seems to be the agent is getting data passed into its tool with json formatting for example: Action Input:

{
  "query": "What are some common variables used in studies regarding human error-based aviation accidents",
  "documents": [
    {
      "title": "The Role of Human Factors in Aviation Ground Operation-Related Accidents",
      "path": "C:/Users/Admin/Desktop/erdcDBFunc/crewAIDocSum/documents/The_role_of_human_factors_in_aviation_ground_operation_related_accidents.pdf"
    }
  ]
}

Thought: It seems there was an error in the action input format. I need to correct the input format to ensure it is a valid key-value dictionary as expected by the Document_Synthesis tool.

How do I prevent this formatting and just pass the inputs as a key value pair?

P7201 avatar May 06 '24 02:05 P7201

Weird we should threat for that, can you share a little more of the log surrounding that error?

joaomdmoura avatar May 06 '24 02:05 joaomdmoura

The first agent loops through a directory of documents and summarizes them. The second agent takes a user query and compares it to the document summaries to determine which documents are needed to answer the question. The names and paths of the necessary documents are passed to a third agent to process for analysis. I'm working on building out a systematic literature review and meta analysis tool. I'd like to go over with you.

Finished chain. [DEBUG]: == [Expert Query Analyzer and Classifier] Task output: ```json { "need_single_doc": true, "need_multiple_docs": false, "documents": [.

Finished chain. [DEBUG]: == [Expert Query Analyzer and Classifier] Task output: ```json { "need_single_doc": true, "need_multiple_docs": false, "documents": [ { "title": "The Role of Human Factors in Aviation Ground Operation-Related Accidents", "path": "C:/Users/Admin/Desktop/erdcDBFunc/crewAIDocSum/documents/The_role_of_human_factors_in_aviation_ground_operation_related_accidents.pdf" } ] }



 [DEBUG]: == Working Agent: Expert Integrative Synthesizer
 [INFO]: == Starting Task: 
            Wait until the query_analysis_agent has completed their task. Take the list of documents from the query_analysis_agent
            to perform your task to synthesize the contents of multiple documents  in order to provide a detailed and comprehensive answer to the query: 'What are some common variables used in studies regarding human error-based aviation accidents '.
            This task involves:
            - Receiving the necessary document paths and titles from the query_analysis_agent to answer the query
            - Analyzing each document  to extract key information, themes, and data points that are directly relevant to the query.
            - Comparing and contrasting the findings across different documents to identify commonalities, discrepancies, and unique insights.
            - Integrating these insights into a coherent narrative that addresses the query's requirements, highlighting how each piece of information contributes to understanding the broader topic.
            - Utilizing advanced NLP techniques to ensure that the synthesis is not only comprehensive but also presents the information in an easily digestible format for the end-user.



> Entering new CrewAgentExecutor chain...
Thought: Before I can synthesize the information from the provided document, I need to extract key information, themes, and data points that are directly relevant to the query about common variables used in studies regarding human error-based aviation accidents. Since I have been provided with the document's title and path, I can proceed to analyze the document using the Document_Synthesis tool.

Action: Document_Synthesis

Action Input:
```json
{
  "query": "What are some common variables used in studies regarding human error-based aviation accidents",
  "documents": [
    {
      "title": "The Role of Human Factors in Aviation Ground Operation-Related Accidents",
      "path": "C:/Users/Admin/Desktop/erdcDBFunc/crewAIDocSum/documents/The_role_of_human_factors_in_aviation_ground_operation_related_accidents.pdf"
    }
  ]
}

P7201 avatar May 06 '24 16:05 P7201

@P7201, @joaomdmoura The problem is the Action Input is not passed verbatim, rather wrapped inside a ```json...``` block. As a workaround, you may want to specifically ask in the task not to do so - i.e., add the following to the task:

IMPORTANT INSTRUCTIONS:
------------------------------
- Action Input, although a JSON dictionary, must *never* be surrounded by backticks!
  It must be passed verbatim as a JSON dictionary.
- "```json ... ```" is not allowed!!!. This is critical, as the tool will not be able to function correctly if this is done.

I find that the agent doesn't always adhere to these instructions on the first attempt, but corrects itself on the second, once tool execution fails. IMO it is better to handle it in the output parser.

avri-schneider avatar May 09 '24 09:05 avri-schneider

@avri-schneider for me it is like

It appears there is a persistent issue with the format of the input. I will ensure that the format strictly adheres to the expected key-value structure. Let's break down the task and ensure each key-value pair is correctly formatted within the input dictionary.

Action: Delegate work to coworker
Action Input:
{
    "task": "Create an investment decision on the stock SPAL based on the provided financial details and analysis.",
    "context": {
        "stock_name": "SPAL",
        "exchange": "NSE",
        "end_date": "2023-12-31",
        "investment_horizon": "long",
   }
}

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

Bitsy-Chuck avatar Jun 23 '24 20:06 Bitsy-Chuck

Can you try the following Action Input?

{ "task": "Create an investment decision on the stock SPAL based on the provided financial details and analysis.", "context": "{"stock_name": "SPAL", "exchange": "NSE", "end_date": "2023-12-31", "investment_horizon": "long"}" }

On Sun, Jun 23, 2024 at 11:06 PM Ojasv Singh @.***> wrote:

@avri-schneider https://github.com/avri-schneider for me it is like

It appears there is a persistent issue with the format of the input. I will ensure that the format strictly adheres to the expected key-value structure. Let's break down the task and ensure each key-value pair is correctly formatted within the input dictionary.

Action: Delegate work to coworker Action Input: { "task": "Create an investment decision on the stock SPAL based on the provided financial details and analysis.", "context": { "stock_name": "SPAL", "exchange": "NSE", "end_date": "2023-12-31", "investment_horizon": "long", } }

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

— Reply to this email directly, view it on GitHub https://github.com/joaomdmoura/crewAI/issues/547#issuecomment-2185309770, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTYRHMS7BXAUJP6PANEO33ZI4TFNAVCNFSM6AAAAABHCIJJ5SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBVGMYDSNZXGA . You are receiving this because you were mentioned.Message ID: @.***>

avri-schneider avatar Jun 23 '24 20:06 avri-schneider

I finally got this working, I had to be very specific in the task description and expected output: return Task( description=f""" Wait until the document_summary_agent has completed their task. Then, using the Query_and_Document_Summary_Analysis tool analyze the given user query: {query} to ascertain the specific information required from the document summaries found here: {summaries_path}. - Use the provided summaries_path to access and review document summaries. - The input format for the action should be a Python dictionary - The input should be a Python dictionary, but it MUST NOT be enclosed in triple backticks or have a JSON label. - The output will be a list of dictionaries detailing relevant documents, including titles and paths. - Extract key words, phrases, and underlying questions from the user's query using advanced NLP techniques. - Match these extracted elements with the information in the document summaries from the summaries loacted in the summaries_path to determine which document(s) could potentially answer the query. - The process should be meticulous to ensure that all possible documents that could answer the query are considered, """, agent=agent, async_execution=False,
expected_output=""" - Provide a list of dictionaries. Each dictionary should contain: - 'title': The title of the document. - 'path': The file path to the document. - You MUST structure your output in the form of a list of dictionaries. - The input SHOULD NOT be enclosed in triple backticks - The input SHOULD NOT have a JSON label. - The input SHOULD NOT have a python label The list format will facilitate the subsequent processing tasks without needing further parsing.
""" )

P7201 avatar Jul 24 '24 22:07 P7201

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 Aug 24 '24 12:08 github-actions[bot]

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

github-actions[bot] avatar Aug 29 '24 12:08 github-actions[bot]