15 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
3ef9ee8886 Merge PR #2513: fix: pick the JSON fence when a code snippet fence comes first
Prefer explicit JSON fences over unlabeled examples, ignore other language fences, and cover both precedence and embedded JSON preservation.
2026-11-14 23:07:03 +08:00
Mohammad Hijjawi
e27aa512df fix: pick the JSON fence when a code snippet fence comes first
parse_json_response extracted only the first fenced block, so a reply
that shows a code snippet (for example a ```python block) before the
fenced JSON payload lost the payload: it returned a list literal from the
snippet or the fallback. Prefer the first fenced block that holds a JSON
object or array, and keep the first block otherwise.
2026-11-07 10:41:08 +00:00
Bingxi Zhao (Frank)
c96440d6ac fix: harden Responses stream parsing (#825) 2026-08-12 16:11:21 +08:00
Bingxi Zhao (Frank)
34ca1cb27c fix(utils): return the longest decodable JSON value, not the first (#692)
The raw_decode scan added for trailing brace-prose returned the first
decodable value in the response. DeepSeek-style reasoning preludes often
embed a small schema example (e.g. {"chapters": []}) before the real
payload, so the example shadowed the actual object and BookEngine's
SpineAgent fell back to a single Overview chapter. Scan every top-level
candidate and keep the longest decode instead.
2026-07-24 17:39:00 +08:00
Cyriellewu
b020686ced fix(json_parser): strip <think> reasoning tags before parsing (#675)
Reasoning models (Qwen, DeepSeek, etc.) emit chain-of-thought inside
<think>...</think> blocks before the JSON payload. parse_json_response()
did not account for this: a brace inside the reasoning was picked up by
the raw_decode scan and returned instead of the real object, silently
yielding wrong or empty data (e.g. empty BookEngine proposal fields).

Strip <think> blocks only on the direct-parse failure path, so a valid
JSON payload whose string values legitimately contain the substring
'<think>' is preserved exactly. Also drop an unclosed leading <think>
prelude up to the first JSON opener, and return the fallback when the
response is reasoning-only with no payload.

Fixes #673

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-24 16:04:42 +08:00
santhreal
19789f19be style(utils): one-line comment on trailing-prose JSON decode 2026-07-22 22:52:15 -07:00
santhreal
5c3e5bf560 fix(utils): decode trailing-prose JSON before repair
json-repair wrapped a valid object plus trailing brace-prose into an array,
corrupting book/question callers that expect a single object. Prefer
raw_decode of the first JSON value before repair.
2026-07-22 22:49:04 -07:00
unknown
77b24725c5 merge: upstream/dev into feature/guided-learning
Resolved 8 conflicts:
- agentic_pipeline.py: keep `import asyncio` (ours)
- deep_question.py: accept upstream's removal of answer_now fast-path
  (refactored into agentic engine in upstream 23ca302); drop dead
  helpers _parse_answer_now_json, _collect_cost_summary, and the
  legacy _run_mimic_mode overload
- pocketbase_store.py, WorkspaceSidebar.tsx, en/zh app.json: keep ours
- playground/page.tsx: keep ours (apiFetch + RESEARCH_SOURCE_OPTIONS),
  also remove pre-existing duplicate top-of-file block left over from
  the earlier a8801f9 merge; add `type ResearchSource` import
- reporting_agent.py: accept upstream's deletion
2026-05-21 23:26:53 +08:00
Bingxi Zhao (Frank)
90a2c14c81 chore: backend + frontend follow-ons for v1.4.0-beta
Wires the new memory / capability / settings / quiz subsystems into
existing surfaces and finishes the chat-pipeline follow-on work.

Backend:
- Session services pick up the cumulative source inventory + new tool
  tags (turn_runtime, sqlite_store, pocketbase_store, protocol,
  base_session_manager).
- LlamaIndex RAG pipeline config / document_loader / retrievers
  tightened; rag/service.py routed to match.
- Sessions / unified_ws / settings / notebook routers updated for
  delete-chat-turn, multi-user, and the new tool surface.
- TutorBot manager + Zulip channel + openai_compat_provider follow-on
  fixes layered on top of the v1.3.10 SSL/Zulip sweeps.
- runtime/{banner, launcher, orchestrator}, services/setup/init,
  prompt/manager, json_parser refined for the runtime-settings
  rewrite.

Frontend:
- Co-Learn pages and session-surfaces removed (folded into chat).
- Chat composer / messages / trace / session panels, sidebars,
  common modals, markdown renderers, and i18n updated for the new
  ask_user / write_note / source-inventory flow.
- Admin, agents, co-writer, playground, book pages picked up the
  shared updates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:08:22 +08:00
unknown
6934db4a91 perf: unified LLM/RAG timeout, per-stage degradation, and code cleanup
- Add stage_failure_counts/stage_failure_notes to LearningProgress for persistent failure tracking
- Wrap RAG retrieval with 10s independent timeout in _call_llm_impl
- Add _call_llm_with_timeout (default 60s) and _call_llm_with_degradation (bounded retry + skip)
- Apply degradation to all 12 stage handlers with stage-specific fallback paths
- Extract _run_interactive_quiz_loop shared helper for practice/practice_quiz
- Extract StructuredStageContent component from page.tsx
- Add TypeError to JSON parse except clauses across 7 files
- Simplify _record_attempt_and_update_mastery to single save exit
- Move import logging to module top in service.py
2026-05-21 00:07:31 +08:00
Bingxi Zhao (Frank)
4b7d24d33e release: v1.2.3 — document attachments, thinking blocks, provider core refactor
- Chat document attachments (PDF/DOCX/XLSX/PPTX) with text extraction
- Reasoning model <think> block display as collapsible cards
- Tri-state send_dimensions toggle for embeddings (#368)
- LLM provider_core module refactor + context_window detection
- Soul template editor (PR #373), Co-Writer save-to-notebook
- Knowledge Base drag-and-drop upload, delete resilience (#370),
  progress persistence, supported-file-types endpoint
- Question generation language fidelity via shared prompt directives
- Settings tour redesign, CLI notebook add-md/replace-md
- Bug fixes: CJK bot name slug, I18nProvider init, Skills default off,
  Moonshot base URL, version badge
- Provider registry: custom_anthropic, thinking_style, alias expansion
- +1900 test lines across 15 new/expanded test files

Made-with: Cursor
2026-04-24 22:36:32 +08:00
Bingxi Zhao (Frank)
77f29cbcc7 fix lint 2026-04-23 19:29:16 +08:00
Bingxi Zhao (Frank)
a4d9bd4860 fix: use sentinel for parse_json_response fallback so None is honored
The original implementation converted `fallback=None` to `{}`,
making `if data is None:` checks dead code in data_structures,
note_agent and reporting_agent. Use a `_UNSET` sentinel so callers
can explicitly request `None` as the failure value.

Also simplify control flow in data_structures and reporting_agent
to avoid raising ValueError inside bare try/except that wouldn't
catch it.

Made-with: Cursor
2026-04-08 12:11:19 +08:00
Bingxi Zhao (Frank)
f3779138ae fix: remove lightrag and unify llm & search config 2026-03-13 23:48:49 +08:00
Bingxi Zhao (Frank)
9c18bf0705 codebase cleanup and decoupled, introduce cli operation 2026-03-13 20:42:16 +08:00