You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]:parse_json_response does not strip <think> reasoning tags, causing empty BookEngine proposal fields #673
I have searched the existing issues and this bug is not already filed.
I believe this is a legitimate bug, not just a question or feature request.
Describe the bug
deeptutor/utils/json_parser.py::parse_json_response() parses JSON from LLM responses,
but it does not strip ... reasoning chains before parsing.
When using models like Qwen / DeepSeek that emit chain-of-thought inside tags
before the JSON, the parser may return {}. In BookEngine's IdeationAgent, this
causes the generated proposal's description, scope, and rationale to be empty.
parse_json_response() fails to extract the JSON, returns {}, and
IdeationAgent._coerce_proposal() fills all fields with empty strings.
This affects all callers of parse_json_response(), not just BookEngine.
Steps to reproduce
Configure a model that outputs tags (e.g., qwen3.7-max).
Go to Book → Create new book.
Enter a user intent and click Generate proposal.
The proposal card appears, but Description, Scope, and Rationale are empty.
Expected Behavior
parse_json_response() should ignore ... content and successfully parse the JSON object. The proposal should contain non-empty description, scope, and rationale.
Related Module
Idea Generation
Configuration Used
Model provider: OpenAI-compatible endpoint serving Qwen3.7-max-2026-06-08 Issue is independent of specific knowledge bases or chat selections.
Logs and screenshots
Additional Information
DeepTutor Version: v1.5.3
Operating System: Windows 11
Python Version: 3.11
Node.js Version: v24.14.0
Browser (if applicable): Chrome 127
Related Issues: none
Verification: After adding think-tag stripping to parse_json_response() in a local branch, the same model and input produce a correct proposal with all fields populated, and the issue no longer reproduces.
Hi! I'd like to work on this. I've traced it to parse_json_response() in deeptutor/utils/json_parser.py — when a <think> reasoning block contains a brace, the raw_decode scan picks up the object from inside the reasoning instead of the real payload. I have a fix + tests ready targeting dev and will open a PR shortly.
Fixed on dev by #675. parse_json_response now strips <think> reasoning after a failed direct parse and before the raw_decode scan, so a brace inside the reasoning can no longer be returned in place of the real payload — and a valid JSON payload whose string values legitimately contain a literal <think> is preserved untouched (regression test added). Will ship in the next release. Thanks @Cyriellewu for the trace and the fix.
Activity
Cyriellewu commentedon Jul 24, 2026
Hi! I'd like to work on this. I've traced it to
parse_json_response()indeeptutor/utils/json_parser.py— when a<think>reasoning block contains a brace, theraw_decodescan picks up the object from inside the reasoning instead of the real payload. I have a fix + tests ready targetingdevand will open a PR shortly.fix(json_parser): strip <think> reasoning tags before parsing (#675)
pancacake commentedon Jul 24, 2026
Fixed on
devby #675.parse_json_responsenow strips<think>reasoning after a failed direct parse and before the raw_decode scan, so a brace inside the reasoning can no longer be returned in place of the real payload — and a valid JSON payload whose string values legitimately contain a literal<think>is preserved untouched (regression test added). Will ship in the next release. Thanks @Cyriellewu for the trace and the fix.fix(json_parser): strip <think> reasoning tags before parsing (HKUDS#675