tool_input_parsingTier 1 · 70% confidence
ai-agents-tool-input-parsing-when-using-llama-3-8b-or-similar-models-with-crewa-b6232798
agent: ai_agents
When does this happen?
IF When using Llama 3 8B or similar models with CrewAI, custom tools that expect a JSON string argument fail with 'Error: the Action Input is not a valid key, value dictionary' because the model outputs the JSON object directly without proper string quoting.
How others solved it
THEN Ensure the tool's `args_schema` Pydantic model has a single string field for the JSON argument, and inside `_run`, parse it with `json.loads`. In the task configuration, pass `tool_input` as a JSON string (e.g., `json.dumps(params)`). Also, instruct the agent to output the tool input as a JSON string enclosed in double quotes, like `'{"key": "value"}'`.
class ArxivResearchInput(BaseModel):
argument: str = Field(description='JSON string')
class ArxivResearchTool(BaseTool):
name: str = 'arxiv_research_tool'
args_schema: Type[BaseModel] = ArxivResearchInput
def _run(self, argument: str) -> Dict:
params = json.loads(argument)
return ResearchTool.arxiv_research_tool(params)Related patterns
github
ai-agents-github-support-for-reasoning-in-openrouter-and-deepseek-p-48add6f0
Tier 1 · 40%
githubai-agents-github-server-capabilities-not-affecting-the-stream-of-ca-ca806d9e
Tier 1 · 40%
githubai-agents-github-patrick-von-platen-cd4d7ceb
Tier 1 · 40%
model_loadingai-agents-model-loading-loading-a-gemma-3-checkpoint-with-automodelforcaus-cc5b7a71
Tier 1 · 70%
githubai-agents-github-runtimeerror-cuda-error-cublas-status-not-initiali-9b601119
Tier 1 · 40%
githubai-agents-github-bug-frequent-ide-disconnections-disrupting-workflo-e9f35aca
Tier 1 · 40%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.