-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
What happened?
When using an Agent with LibreChat web search enabled, some searches complete successfully, but searches that hit blocked/protected pages (such as Reddit, Facebook and Pinterest) can fail and then crash the agent pipeline with:
Cannot read properties of undefined (reading 'role')
This appears to happen after upstream web-search component failures such as:
- Jina reranker
429 Too Many Requests - Firecrawl scraper
403 Forbidden
Public-web queries can work, which suggests the core agent/tool flow is functional, but scraper/reranker failure handling may be leaving an invalid or undefined message in agent state.
Expected behavior
If a scraper or reranker fails for one or more sources, LibreChat should:
- handle the failed source gracefully
- continue with remaining usable results, or return a normal partial-failure message
- not crash in LangGraph / message reduction
Actual behavior
The agent thinks/searches for a bit, then fails with:
Something went wrong. Here's the specific error message we encountered: An error occurred while processing the request: Cannot read properties of undefined (reading 'role')
Backend logs show the crash occurs in the agent completion path and then inside LangGraph message coercion.
Version Information
LibreChat version: 0.8.3
Model:
- MiniMax 2.5 (via OpenAI-compatible/custom endpoint in LibreChat)
Web search setup:
- Search provider: SearXNG
- Scraper: Firecrawl
- Reranker: initially Jina, later changed to Cohere
- No explicit
webSearch:block inlibrechat.yamlinitially; using default web-search env/UI behavior
Control / A-B behavior
This query worked successfully and did not appear to return social/protected sources:
Who was the first person to swim across the English Channel?
This suggests the issue is not a general model/tool failure and is more likely triggered by upstream search-source failures.
Additional notes
-
Missing provider auth lookup errors also appeared in logs, for example:
No plugin auth SERPER_API_KEY foundNo plugin auth SEARXNG_API_KEY foundNo plugin auth FIRECRAWL_API_URL foundNo plugin auth JINA_API_KEY foundNo plugin auth COHERE_API_KEY found
However, since public-web queries can succeed, these do not appear to be the primary failure by themselves.
Hypothesis
It looks like failed scrape/rerank results may be leaving an undefined entry in the agent message state, which later crashes LangGraph when LibreChat tries to coerce messages and read .role.
What I already tried
- Switched reranker from Jina to Cohere
- Confirmed that a public-web query succeeds
- Observed that failures correlate with protected/social sources and upstream 403/429 errors
Version Information
ghcr.io/danny-avila/librechat:v0.8.3 028dd86ddb43 3.42GB 748MB U
Steps to Reproduce
- Configure LibreChat 0.8.3 with Agent web search enabled
- Use:
- SearXNG for search
- Firecrawl for scraping
- Jina or Cohere for reranking
- Use a query that tends to return protected/social pages (Facebook, Reddit, etc.)
- Wait for the agent to search/scrape
- Observe that upstream scrape/rerank errors occur
- The request then aborts with
Cannot read properties of undefined (reading 'role')
Failing prompt: "Find me the cheapest price on Lehman's stainless steel cider press"
Working prompt: "Who was the first person to swim across the English Channel?"
What browsers are you seeing the problem on?
Chrome
Relevant log output
#### Secondary crash
{"level":"error","message":"[api/server/controllers/agents/client.js #sendCompletion] Operation aborted Cannot read properties of undefined (reading 'role')","pregelTaskId":"962d881e-1370-5be3-b8b9-ac0ed57d29be","stack":"TypeError: Cannot read properties of undefined (reading 'role')\n at _isMessageFieldWithRole (/app/node_modules/@langchain/core/dist/messages/base.cjs:396:21)\n at coerceMessageLikeToMessage (/app/node_modules/@langchain/core/dist/messages/utils.cjs:136:52)\n at Array.map (<anonymous>)\n at BinaryOperatorAggregate.messagesStateReducer [as operator] (/app/node_modules/@langchain/langgraph/dist/graph/message.cjs:20:38)\n at BinaryOperatorAggregate.update (/app/node_modules/@langchain/langgraph/dist/channels/binop.cjs:57:35)\n at _applyWrites (/app/node_modules/@langchain/langgraph/dist/pregel/algo.cjs:177:35)\n at _localRead (/app/node_modules/@langchain/langgraph/dist/pregel/algo.cjs:76:9)\n at __pregel_read (/app/node_modules/@langchain/langgraph/dist/pregel/algo.cjs:560:96)\n at ChannelRead.doRead (/app/node_modules/@langchain/langgraph/dist/pregel/read.cjs:57:20)\n at /app/node_modules/@langchain/langgraph/dist/graph/state.cjs:664:49","timestamp":"2026-03-17T05:15:21.149Z"}
#### Upstream scraper failure
{"level":"error","message":"Error scraping https://www.facebook.com/groups/FarmDirectMinnesota/posts/1419044669191349/: Firecrawl API request failed: Request failed with status code 403","timestamp":"2026-03-17T05:15:19.488Z"}
#### Earlier upstream reranker failure with same downstream crash
AxiosError: Request failed with status code 429
at async JinaReranker.rerank (/app/node_modules/@librechat/agents/dist/cjs/tools/search/rerankers.cjs:40:30)
at async getHighlights (/app/node_modules/@librechat/agents/dist/cjs/tools/search/search.cjs:67:20)
at async Object.processSources (/app/node_modules/@librechat/agents/dist/cjs/tools/search/search.cjs:502:13)
and then:
[api/server/controllers/agents/client.js #sendCompletion] Operation aborted Cannot read properties of undefined (reading 'role')Screenshots
Code of Conduct
- I agree to follow this project's Code of Conduct