Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

Revert "fix: use parse_json_response for LLM outputs to handle markdown fences (#263)"

Bingxi Zhao (Frank)31adc675499d
diff --git a/deeptutor/agents/guide/agents/design_agent.py b/deeptutor/agents/guide/agents/design_agent.py
index 5945a501c..9d52d82ca 100644
--- a/deeptutor/agents/guide/agents/design_agent.py
+++ b/deeptutor/agents/guide/agents/design_agent.py
@@ -8,7 +8,6 @@ import json
from typing import Optional
from deeptutor.agents.base_agent import BaseAgent
-from deeptutor.utils.json_parser import parse_json_response
class DesignAgent(BaseAgent):
@@ -74,7 +73,7 @@ class DesignAgent(BaseAgent):
response = "".join(_chunks)
try:
- result = parse_json_response(response, logger_instance=self.logger)
+ result = json.loads(response)
if isinstance(result, list):
knowledge_points = result
diff --git a/deeptutor/agents/question/agents/idea_agent.py b/deeptutor/agents/question/agents/idea_agent.py
index 60608fe07..23d8cf41e 100644
--- a/deeptutor/agents/question/agents/idea_agent.py
+++ b/deeptutor/agents/question/agents/idea_agent.py
@@ -9,7 +9,6 @@ import json
from typing import Any
from deeptutor.agents.base_agent import BaseAgent
-from deeptutor.utils.json_parser import parse_json_response
from deeptutor.agents.question.models import QuestionTemplate
from deeptutor.core.trace import build_trace_metadata, new_call_id
from deeptutor.tools.rag_tool import rag_search
@@ -228,7 +227,7 @@ class IdeaAgent(BaseAgent):
):
_chunks.append(_c)
response = "".join(_chunks)
- payload = parse_json_response(response, logger_instance=self.logger)
+ payload = json.loads(response)
ideas_raw = payload.get("ideas", [])
if not isinstance(ideas_raw, list):
ideas_raw = []
diff --git a/deeptutor/agents/research/agents/note_agent.py b/deeptutor/agents/research/agents/note_agent.py
index f61fcd1e0..fca86cdd4 100644
--- a/deeptutor/agents/research/agents/note_agent.py
+++ b/deeptutor/agents/research/agents/note_agent.py
@@ -11,7 +11,6 @@ from typing import Any, Optional
from deeptutor.agents.base_agent import BaseAgent
from deeptutor.agents.research.data_structures import ToolTrace
from deeptutor.core.trace import build_trace_metadata, new_call_id
-from deeptutor.utils.json_parser import parse_json_response
from ..utils.json_utils import extract_json_from_text
@@ -159,8 +158,9 @@ class NoteAgent(BaseAgent):
def _extract_summary_by_rule(self, tool_type: str, raw_answer: str) -> str:
"""Extract a concise summary from structured tool output without LLM."""
- data = parse_json_response(raw_answer, fallback=None)
- if data is None:
+ try:
+ data = json.loads(raw_answer)
+ except Exception:
return ""
tool_type = (tool_type or "").lower()
diff --git a/deeptutor/agents/research/agents/reporting_agent.py b/deeptutor/agents/research/agents/reporting_agent.py
index 59d1e2989..a1ab7a315 100644
--- a/deeptutor/agents/research/agents/reporting_agent.py
+++ b/deeptutor/agents/research/agents/reporting_agent.py
@@ -1507,11 +1507,9 @@ class ReportingAgent(BaseAgent):
@staticmethod
def _strip_json_wrapper(resp: str) -> str:
"""Best-effort extraction of readable text from a JSON response."""
- from deeptutor.utils.json_parser import parse_json_response
+ import json as _json
try:
- obj = parse_json_response(resp.strip(), fallback=None)
- if obj is None:
- raise ValueError("parse failed")
+ obj = _json.loads(resp.strip())
if isinstance(obj, dict):
for key in ("report", "content", "text", "markdown", "output"):
if key in obj and isinstance(obj[key], str):
diff --git a/deeptutor/agents/research/data_structures.py b/deeptutor/agents/research/data_structures.py
index 2ab146469..0fc242639 100644
--- a/deeptutor/agents/research/data_structures.py
+++ b/deeptutor/agents/research/data_structures.py
@@ -11,8 +11,6 @@ import json
from pathlib import Path
from typing import Any
-from deeptutor.utils.json_parser import parse_json_response
-
class TopicStatus(Enum):
"""Topic block status enumeration"""
@@ -81,9 +79,7 @@ class ToolTrace:
# Try to parse as JSON and truncate intelligently
try:
- data = parse_json_response(raw_answer, fallback=None)
- if data is None:
- raise ValueError("not JSON")
+ data = json.loads(raw_answer)
# If it's a dict with common RAG response fields, truncate content fields
if isinstance(data, dict):
diff --git a/deeptutor/agents/research/utils/citation_manager.py b/deeptutor/agents/research/utils/citation_manager.py
index a8937abf9..8b0f00fad 100644
--- a/deeptutor/agents/research/utils/citation_manager.py
+++ b/deeptutor/agents/research/utils/citation_manager.py
@@ -11,7 +11,6 @@ from pathlib import Path
from typing import Any
from deeptutor.services.path_service import get_path_service
-from deeptutor.utils.json_parser import parse_json_response
class CitationManager:
@@ -294,7 +293,7 @@ class CitationManager:
try:
# Parse raw_answer to extract source information
- answer_data = parse_json_response(raw_answer)
+ answer_data = json.loads(raw_answer)
# Extract source documents if available
# Common fields in RAG responses: chunks, documents, sources, context
@@ -350,7 +349,7 @@ class CitationManager:
try:
# Parse raw_answer to extract web source information
- answer_data = parse_json_response(raw_answer)
+ answer_data = json.loads(raw_answer)
web_sources = []
@@ -397,7 +396,7 @@ class CitationManager:
try:
# Parse raw_answer JSON
- answer_data = parse_json_response(raw_answer)
+ answer_data = json.loads(raw_answer)
papers = answer_data.get("papers", [])
if not papers:
diff --git a/deeptutor/agents/solve/agents/planner_agent.py b/deeptutor/agents/solve/agents/planner_agent.py
index 20cee3c12..3c31a954a 100644
--- a/deeptutor/agents/solve/agents/planner_agent.py
+++ b/deeptutor/agents/solve/agents/planner_agent.py
@@ -15,7 +15,6 @@ from typing import Any
from deeptutor.agents.base_agent import BaseAgent
from deeptutor.core.trace import build_trace_metadata, derive_trace_metadata, new_call_id
-from deeptutor.utils.json_parser import parse_json_response
from ..memory.scratchpad import Plan, PlanStep, Scratchpad
from ..tool_runtime import SolveToolRuntime
@@ -215,7 +214,7 @@ class PlannerAgent(BaseAgent):
):
parts.append(chunk)
response = "".join(parts)
- payload = parse_json_response(response, logger_instance=logger)
+ payload = json.loads(response)
queries = payload.get("queries", [])
if not isinstance(queries, list):
queries = []