[Bug]: strict json.loads on lax LLM JSON breaks extraction (trailing commas) and 500s /flush
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start with everalgo/user_memory/episode.py and its _extract_json_object() parsing path, then compare the related call sites in profile.py, atomic_fact.py, and foresight.py. Reproduce with the trailing-comma JSON example in the issue and trace how extraction errors reach /api/v2/memory/flush. Done when malformed LLM JSON no longer crashes flush with a 500 and extraction failures are handled as described.
索引モデルが issue の本文から書いたものです。
説明
Title: memorize_extraction_failed with strict json.loads on lax LLM JSON; extraction error crashes /flush with 500
Environment
- everos 1.5.1 (uv tool install), everalgo vendored
[llm]provider: DeepSeek (deepseek-chat, OpenAI-compatible), embeddings: DashScopetext-embedding-v4- Observed under real multi-session traffic (~170
/add, ~50/flushper day)
Symptoms
Intermittent (14 occurrences in ~30h) on flush-triggered extraction:
memorize_extraction_failed error='JSONDecodeError: Expecting property name enclosed in double quotes: line 4 column 1 (char 2954)'
unhandled_exception exception_type=JSONDecodeError path=/api/v2/memory/flush
- The parse failure is unhandled at the route level:
POST /api/v2/memory/flushreturns 500 instead of degrading gracefully; the memcells stay buffered and retry later, delaying memory availability and logging a traceback every time. episode_extract_retryre-prompts, but retries reproduce the same malformed JSON.
Root cause
LLM output (DeepSeek in our case) is occasionally not strict RFC-8259 JSON — e.g. trailing commas before a closing brace ({..., }), which produces exactly Expecting property name enclosed in double quotes: line N column 1. The extraction path does strict parsing with no repair:
everalgo/user_memory/episode.py:_extract_json_object()(brace-balanced substring) → barejson.loads(json_str)— noresponse_format={"type":"json_object"}enforcement, no sanitization.- Same pattern in
profile.py(×3 sites),atomic_fact.py,foresight.py. (everalgo.llm.parse.parse_llm_json_objectalready has a multi-strategy parser, but these modules don't use it.)
GLM and some other providers happen to emit strict JSON, which masks the bug; switching providers exposes it.
Suggested fixes (any one suffices; first is smallest)
- One repair pass before strict parsing: strip commas directly preceding
}/], e.g.re.sub(r",\s*([}\]])", r"\1", json_str)onJSONDecodeError, retry once. - Route all extractor call sites through
everalgo.llm.parse.parse_llm_json_objectand add the same repair as a strategy there (single choke point — the four_extract_json_objectcopies are already duplicated). - Optionally enforce
response_format={"type": "json_object"}for OpenAI-compatible providers that support it. - Separately: catch extraction exceptions in the
/flushhandler and return a structured error envelope instead of an unhandled 500.
Repro
Any OpenAI-compatible model that emits a trailing comma (DeepSeek deepseek-chat does this intermittently) + a flush that triggers episode extraction. Local repro of the parse failure: json.loads('{\n"title": "<1200 chars>",\n"content": "<1500 chars>",\n}') → JSONDecodeError: Expecting property name enclosed in double quotes: line 4 column 1.
Local workaround
Patched the four modules with a _loads_lenient helper (repair-once-on-JSONDecodeError); failures stopped. Happy to send the diff/PR.
- 主要言語
- Python
- スター
- 13.3k
- フォーク
- 926
- 平均マージ
- 19時間 29分
- マージ済み PR(30日)
- 43
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
EverMind-AI/EverOS のほかの issue
-
難易度 2/5 半日 初心者へのやさしさ 62/100
EverMind-AI/EverOS#414 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
EverMind-AI/EverOS#558 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
EverMind-AI/EverOS#551 ·
メンテナーはふだん 1 日以内に返信
-
memory: keep a raw input log of /add requests, independent of extraction対応中かも @chuiwenwei が 1 日前に担当しました。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
EverMind-AI/EverOS#537 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
memorize(): make delivery resumable per memcell so retries and replays are idempotent対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
EverMind-AI/EverOS#516 ·
メンテナーはふだん 1 日以内に返信
EverMind-AI/EverOS の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
huggingface/accelerate#4511 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
pylint-dev/pylint#11791 ·
メンテナーはふだん 1 日以内に返信
-
Rasterio granule reads never retry, so one 503 (Service Unavailable) fails the whole request対応中かも @chuckwondo が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
developmentseed/titiler-cmr#305 ·
メンテナーはふだん 1 日以内に返信
-
community enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信