langchain-ai/deepagents · error · ValueError
Store item does not contain valid content field. Got: {store
Error message
Store item does not contain valid content field. Got: {store_item.value.keys()} What it means
When converting a persisted BaseStore item into `FileData`, `_convert_store_item_to_file_data` expects a `content` key in the item's value. If `value.get('content')` is None (missing or explicitly None), the item is considered corrupt/incompatible and a ValueError is raised listing the keys that were actually present.
Source
Thrown at libs/deepagents/deepagents/backends/store.py:188
def _convert_store_item_to_file_data(self, store_item: Item) -> FileData:
"""Convert current and legacy persisted store content to `FileData`.
Args:
store_item: The store `Item` containing file data.
Returns:
`FileData` with string content and encoding. Legacy `list[str]`
content is joined without modifying the persisted item. Includes
`created_at` and `modified_at` when present.
Raises:
ValueError: If the store item has no content.
TypeError: If content is neither a string nor a legacy list of strings.
"""
raw_content = store_item.value.get("content")
if raw_content is None:
msg = f"Store item does not contain valid content field. Got: {store_item.value.keys()}"
raise ValueError(msg)
if isinstance(raw_content, list) and all(isinstance(line, str) for line in raw_content):
content = "\n".join(raw_content)
elif isinstance(raw_content, str):
content = raw_content
else:
msg = f"Store item `content` must be a `str` or legacy `list[str]`, got {type(raw_content).__name__}."
raise TypeError(msg)
result = FileData(
content=content,
encoding=store_item.value.get("encoding", "utf-8"),
)
if "created_at" in store_item.value and isinstance(store_item.value["created_at"], str):
result["created_at"] = store_item.value["created_at"]
if "modified_at" in store_item.value and isinstance(store_item.value["modified_at"], str):
result["modified_at"] = store_item.value["modified_at"]
return resultView on GitHub (pinned to a1af029e6e)
Solutions
- Ensure every store item written includes a `content` key (str or list[str]) under `value`
- Migrate or delete legacy store entries that lack `content` before reading them through StoreBackend
- Filter store search results to items your app wrote (e.g. include a `kind` marker in value and skip others)
- Inspect the reported keys in the message to find which schema the item actually uses
Example fix
// before
store.put(('filesystem',), '/a.txt', {'text': 'hello'})
// after
store.put(('filesystem',), '/a.txt', {'content': 'hello'}) Defensive patterns
Strategy: validation
Validate before calling
def writable_value(content, encoding='utf-8'):
if content is None:
raise ValueError('content is required')
if isinstance(content, str) or (isinstance(content, list) and all(isinstance(l, str) for l in content)):
return {'content': content, 'encoding': encoding}
raise TypeError(f'unsupported content: {type(content).__name__}')
store.put(('filesystem',), '/a.txt', writable_value('hello')) Type guard
def has_content(value: dict) -> bool:
c = value.get('content')
return c is not None and (
isinstance(c, str)
or (isinstance(c, list) and all(isinstance(l, str) for l in c))
) Try / catch
try:
data = backend.read('/a.txt')
except ValueError as exc:
if 'does not contain valid content field' in str(exc):
data = None # skip/migrate the corrupt store item
else:
raise Prevention
- Always include a `content` key when putting items into the store
- Share a single write helper so all writers use the same value schema
- Migrate or delete legacy entries lacking `content` before reading
- Tag items with a schema/version key and skip foreign entries in searches
When it happens
Trigger: Reading store items written by other code that used a different value schema (no `content` key); store entries manually deleted/partially written; deserializing items from a different backend or an older/custom writer that stored content under a different key.
Common situations: Upgrading from a custom store writer to StoreBackend; sharing one BaseStore between multiple apps with conflicting schemas; hand-seeding an InMemoryStore in tests with items lacking `content`.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Store item `content` must be a `str` or legacy `list[str]`,
- Could not parse embedded resource block. Block expected eith
- {question_type} question {question_text!r} must not define '
- Offload server returned a non-object response.
- Offload server returned an invalid operation response.
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/5a4ce4844407ef29.
Report an issue: GitHub.