mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:50:36 +08:00
A course held the right model — the syllabus that gives progress a
denominator, resources as references, conventions apart from the
assistant's own notes — but almost nothing crossed the edges between it
and the surfaces it was supposed to contain.
Getting in. Course Study was offered in the composer's mode menu while
the only way to bind a course was a link on the course page, so choosing
it there produced a conversation identical to an inert one, and the mode
advised pressing a button that did not exist. The composer now carries
the binding next to the mode: shown whenever there is one, and offered
as an unfinished field in Course Study when there is not. `_course_id`
rides every turn, so detaching detaches and the pill can never drift
from what the turn actually saw.
What a conversation inherits. `default_capability` and `default_persona`
were stored, validated and returned by the API while changing nothing:
`_apply_course_defaults` only fills fields a payload *omits*, and this
composer always sent all of them. They are applied client-side now,
along with the course's knowledge bases, where the learner can watch the
mode and material become the course's before they type. The dialog grows
the editor they never had.
Conventions. "Every conversation in this course starts knowing these" was
true only if the model happened to call `course_overview`. They ride in
the per-turn summary now, and — because the promise is not scoped to one
mode — in the system prompt of any course-bound turn.
Coming back. Mastery Path and Immersive Reading now read `?course=`,
scope themselves to it, and attach whatever is built there; the tiles and
hand-offs pass it; the picker offers to start one. A course could only
ever reference what already existed, so filling a new one meant leaving,
building, and remembering to return.
Hand-offs. A target with no ref stored an opening line for an index that
never consumes it, which then surfaced weeks later in an unrelated path.
An unresolvable ref was passed straight through: observed live, a
syllabus unit id ("u2") sent as a mastery path, producing a card pointing
at a page that does not exist. Refs are checked against the subsystem
that owns them — existence, not membership, since a path built outside
this course routes perfectly well.
Also: the sidebar groups conversations by course, so filing them is
finally readable; a course-scoped notebook console no longer shows
another course's notes beside a list saying there are none (the clear
raced an in-flight detail fetch that landed after it); a hand-off the
model also printed as prose is not rendered twice; a provider error is no
longer stored as a conversation's permanent title; `/space/courses` goes,
having been an unreferenced copy of `/courses`; and the Visualize mode
description gets its missing Chinese.
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
from __future__ import annotations
|
||
|
||
from deeptutor.services.session.turn_runtime import _sanitize_session_title
|
||
|
||
|
||
def test_sanitize_session_title_removes_reasoning_block() -> None:
|
||
raw = "<think>\nNeed a concise title.\n</think>\n标题:AgenticRAG 定义"
|
||
|
||
assert _sanitize_session_title(raw) == "AgenticRAG 定义"
|
||
|
||
|
||
def test_sanitize_session_title_falls_back_when_only_reasoning_remains() -> None:
|
||
raw = "<think>\nStill deciding on the title."
|
||
|
||
assert _sanitize_session_title(raw) == ""
|
||
|
||
|
||
def test_provider_errors_do_not_become_session_titles() -> None:
|
||
"""``llm_stream`` surfaces a provider failure as streamed content.
|
||
|
||
A bad key therefore yields a short, well-formed string that the sanitizer
|
||
happily trims and stores as the conversation's name, where it stays forever
|
||
and follows the session into every list that shows it. Routing these to the
|
||
existing "no title" fallback is what makes that impossible.
|
||
"""
|
||
from deeptutor.services.session.turn_runtime import _looks_like_error_payload
|
||
|
||
assert _looks_like_error_payload(
|
||
"Error: {'message': 'Authentication Fails, Your api key: *** is invalid'}"
|
||
)
|
||
assert _looks_like_error_payload('{"error": {"code": 401}}')
|
||
assert _looks_like_error_payload("错误:调用失败")
|
||
assert _looks_like_error_payload("Traceback (most recent call last):")
|
||
|
||
|
||
def test_real_titles_survive_the_error_guard() -> None:
|
||
"""A false positive silently replaces a good title with a truncated question."""
|
||
from deeptutor.services.session.turn_runtime import _looks_like_error_payload
|
||
|
||
for title in (
|
||
"操作系统概述",
|
||
"Deadlock detection basics",
|
||
"Error handling in Rust",
|
||
"错误处理的三种模式",
|
||
"",
|
||
):
|
||
assert not _looks_like_error_payload(title), title
|