HKUDS/DeepTutor · error · ValueError
ConceptDesignAgent prompts are not configured.
Error message
ConceptDesignAgent prompts are not configured.
What it means
Catch-all in _extract_pdf: any unexpected exception from pypdf while reading pages is wrapped in CorruptDocumentError with the underlying message appended. It signals a malformed or unreadable PDF rather than a specific known condition.
Source
Thrown at deeptutor/agents/math_animator/agents/concept_design_agent.py:42
agent_name="concept_design_agent",
api_key=api_key,
base_url=base_url,
api_version=api_version,
language=language,
)
async def process(
self,
*,
user_input: str,
output_mode: str,
analysis: ConceptAnalysis,
style_hint: str,
) -> SceneDesign:
system_prompt = self.get_prompt("system")
user_template = self.get_prompt("user_template")
if not system_prompt or not user_template:
raise ValueError("ConceptDesignAgent prompts are not configured.")
user_prompt = user_template.format(
user_input=user_input.strip(),
output_mode=output_mode,
style_hint=style_hint.strip() or "(none)",
analysis_json=json.dumps(analysis.model_dump(), ensure_ascii=False, indent=2),
)
_chunks: list[str] = []
async for _c in self.stream_llm(
user_prompt=user_prompt,
system_prompt=system_prompt,
response_format={"type": "json_object"},
stage="concept_design",
trace_meta=build_trace_metadata(
call_id=new_call_id("math-design"),
phase="concept_design",
label="Concept design",
call_kind="math_concept_design",View on GitHub (pinned to 3e82f13042)
Solutions
- Repair the PDF first: qpdf --decrypt or Ghostscript can rebuild broken xref tables
- Re-download/re-upload the file if it was truncated
- Install pymupdf — fitz is tried first and tolerates many malformed PDFs pypdf rejects
Example fix
// before
text = extract_text_from_bytes(corrupted, filename="bad.pdf")
// after
import subprocess
tmp = "/tmp/bad.pdf"; open(tmp,"wb").write(corrupted)
subprocess.run(["qpdf", "--decrypt", tmp, "/tmp/fixed.pdf"], check=True)
text = extract_text_from_bytes(open("/tmp/fixed.pdf","rb").read(), filename="bad.pdf") Defensive patterns
Strategy: fallback
Validate before calling
import fitz
try:
with fitz.open(stream=data, filetype="pdf") as doc:
doc.page_count # forces full open; fitz tolerates many broken PDFs
except Exception:
repair_or_reject(fn) Try / catch
except CorruptDocumentError as e:
if "failed to read PDF" in str(e):
repaired = qpdf_repair(data)
if repaired:
text = extract_text_from_bytes(repaired, filename=fn) Prevention
- Verify upload completeness (content-length vs actual bytes)
- Repair malformed PDFs with qpdf/Ghostscript before extraction
When it happens
Trigger: pypdf throws ValueError ('stream has ended unexpectedly'), structural errors on truncated PDFs, or AssertionError on malformed xref tables while enumerating reader.pages.
Common situations: Truncated uploads (interrupted transfers), corrupted email attachments, hand-crafted or PDFs written by buggy generators.
Related errors
- CodeGeneratorAgent retry prompts are not configured.
- The model provider interrupted this response. Please retry.
- Unable to reach the model provider. Please retry.
- CodeGeneratorAgent generation prompts are not configured.
- ConceptAnalysisAgent prompts are not configured.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/9bec38cc4542898a.
Report an issue: GitHub.