-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Open
Labels
Description
Description
Getting the following Pydantic error while saving to memory.
ERROR:root:OpenAI API call failed: 1 validation error for TaskEvaluation
Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='```json\n{\n "assessmen... ]\n }\n ]\n}\n```', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/json_invalid
[2026-02-18 18:17:49][ERROR]: Failed to add to long term memory: Failed to convert text into a Pydantic model due to validation error: 1 validation error for TaskEvaluation
Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='```json\n{\n "assessmen... ]\n }\n ]\n}\n```', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/json_invalid
Steps to Reproduce
- Run the POC code below.
- Go through the console logs.
from crewai import Agent, Task, Crew, Process
import os
from dotenv import load_dotenv
# Define agents
load_dotenv()
researcher = Agent(
role="Senior Researcher",
goal="Find comprehensive information on the given topic",
backstory="You are an experienced researcher skilled at finding relevant information.",
verbose=True,
)
writer = Agent(
role="Report Writer",
goal="Create a well-structured report based on research findings",
backstory="You are a skilled writer who turns research into clear reports.",
verbose=True,
)
# Define tasks
research_task = Task(
description="Research the topic: {topic}",
expected_output="A list of key findings about the topic.",
agent=researcher,
)
writing_task = Task(
description="Write a report based on the research findings.",
expected_output="A comprehensive report in markdown format.",
agent=writer,
context=[research_task],
)
# Create crew with memory enabled and a custom embedding model
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
process=Process.sequential,
memory=True,
embedder={
"provider": "openai",
"config": {
"model_name": "text-embedding-3-small",
"api_key":os.getenv("API_KEY"),
"api_base": os.getenv("BASE_URL")
},
},
verbose=True,
)
# Kick off the crew
result = crew.kickoff(inputs={"topic": "AI in Healthcare"})
print(result.raw)
Expected behavior
CrewAI should successfully parse LLM output and save task evaluations to long-term memory without validation errors.
Screenshots/Code snippets
Operating System
macOS Sonoma
Python Version
3.10
crewAI Version
1.9.3
crewAI Tools Version
1.9.3
Virtual Environment
Venv
Evidence
.
Possible Solution
.
Additional context
I am already aware of the following issues, and I am on the latest version of CrewAI. It looks like this hasn’t been resolved yet:
Reactions are currently unavailable