Skip to content

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

docs:update readme

Bingxi Zhao (Frank)2cdbab4b639f
diff --git a/README.md b/README.md
index be364ed72..defa6238f 100644
--- a/README.md
+++ b/README.md
@@ -174,7 +174,7 @@ DeepTutor ships four installation paths. They all share one workspace layout: se
> ✨ **v1.4.4 is live.** `pip install -U deeptutor` picks up the latest stable. Pre-releases (when available) opt in with `pip install --pre -U deeptutor`.
<details>
-<summary><b>Option 1 — Install From PyPI</b></summary>
+<summary><b>Option 1 — Install From PyPI</b> · full local Web app + CLI, no clone required</summary>
Full local Web app + CLI, no clone required. Needs **Python 3.11+** and a **Node.js 20+** runtime on PATH (the packaged Next.js standalone server is spawned by `deeptutor start`).
@@ -192,7 +192,7 @@ After `deeptutor start`, open the frontend URL printed in the terminal — by de
</details>
<details>
-<summary><b>Option 2 — Install From Source</b></summary>
+<summary><b>Option 2 — Install From Source</b> · develop against a checkout</summary>
For development against a checkout. Use **Python 3.11+** and **Node.js 22 LTS** to match CI and Docker.
@@ -256,7 +256,7 @@ deeptutor start
</details>
<details>
-<summary><b>Option 3 — Docker</b></summary>
+<summary><b>Option 3 — Docker</b> · one self-contained container</summary>
One container for the full Web app. Images on GitHub Container Registry:
@@ -328,29 +328,8 @@ Docker Desktop (macOS/Windows) usually resolves `host.docker.internal` without `
</details>
-### Code Execution Sandbox (office skills)
-
-The built-in office skills — **docx / pdf / pptx / xlsx** — work by having the
-model write a short Python script (`python-docx`, `reportlab`, `openpyxl`, …),
-run it through the `exec` / `code_execution` tools, and hand back a download URL.
-Those tools mount whenever a sandbox backend is active, which it is **by default**
-in every deployment shape:
-
-- **Local (Option 1 / 2) and Docker (Option 3, single container):** a restricted
- subprocess sandbox runs the model's code (on the host locally, or inside the
- container under Docker — the container being its own isolation boundary).
-- **docker-compose:** routed instead to a hardened, least-privileged **runner
- sidecar** (`Dockerfile.runner`) via `DEEPTUTOR_SANDBOX_RUNNER_URL` — the
- strongest posture, and preferred automatically when present.
-
-The subprocess sandbox is controlled by the `sandbox_allow_subprocess` setting in
-`data/user/settings/system.json` (default `true`). Running model-generated code
-on your host is a real trust decision — set it to `false` (or export
-`DEEPTUTOR_SANDBOX_ALLOW_SUBPROCESS=0`) to disable host-side execution, at the
-cost of the office skills no longer being able to produce files.
-
<details>
-<summary><b>Option 4 — CLI Only</b></summary>
+<summary><b>Option 4 — CLI Only</b> · no Web UI, from a source checkout</summary>
When you don't need the Web UI. The CLI-only package is installed from a source checkout, not from PyPI.
@@ -389,6 +368,30 @@ The local `deeptutor-cli` install ships no Web assets or server dependencies. Ke
</details>
+<details>
+<summary><b>Code Execution Sandbox (office skills)</b> · running model-generated code for docx / pdf / pptx / xlsx</summary>
+
+The built-in office skills — **docx / pdf / pptx / xlsx** — work by having the
+model write a short Python script (`python-docx`, `reportlab`, `openpyxl`, …),
+run it through the `exec` / `code_execution` tools, and hand back a download URL.
+Those tools mount whenever a sandbox backend is active, which it is **by default**
+in every deployment shape:
+
+- **Local (Option 1 / 2) and Docker (Option 3, single container):** a restricted
+ subprocess sandbox runs the model's code (on the host locally, or inside the
+ container under Docker — the container being its own isolation boundary).
+- **docker-compose:** routed instead to a hardened, least-privileged **runner
+ sidecar** (`Dockerfile.runner`) via `DEEPTUTOR_SANDBOX_RUNNER_URL` — the
+ strongest posture, and preferred automatically when present.
+
+The subprocess sandbox is controlled by the `sandbox_allow_subprocess` setting in
+`data/user/settings/system.json` (default `true`). Running model-generated code
+on your host is a real trust decision — set it to `false` (or export
+`DEEPTUTOR_SANDBOX_ALLOW_SUBPROCESS=0`) to disable host-side execution, at the
+cost of the office skills no longer being able to produce files.
+
+</details>
+
### Configuration Reference
<details>
diff --git a/deeptutor/services/session/turn_runtime.py b/deeptutor/services/session/turn_runtime.py
index dc26fd405..ee10ddf44 100644
--- a/deeptutor/services/session/turn_runtime.py
+++ b/deeptutor/services/session/turn_runtime.py
@@ -1703,14 +1703,20 @@ class TurnRuntimeManager:
)
await self._flush_buffered_events(execution)
await self.store.update_turn_status(turn_id, "completed")
+ if pending_done_event is None:
+ pending_done_event = StreamEvent(
+ type=StreamEventType.DONE,
+ source=capability_name,
+ metadata={"status": "completed"},
+ )
+ await self._publish_live_event(execution, pending_done_event)
+ stream_done_sent = True
if not is_regenerate:
- # The frontend disconnects from this turn's WS subscription
- # shortly after ``done`` (with a small grace window), so we
- # generate the title here — inside the try block, before
- # finally sends the ``None`` sentinel to subscribers — so
- # the ``session_meta`` event still reaches them. The LLM
- # scope set up at turn start is still active in this
- # context, meaning the user's selected model is used.
+ # Title generation is post-turn metadata. Keep it after DONE
+ # so the composer and duration clock stop as soon as the
+ # assistant answer is saved; the frontend keeps this socket
+ # open briefly so the later ``session_meta`` title update can
+ # still arrive.
try:
await self._maybe_generate_session_title(
execution=execution,
@@ -1719,14 +1725,6 @@ class TurnRuntimeManager:
)
except Exception:
logger.debug("Failed to generate session title", exc_info=True)
- if pending_done_event is None:
- pending_done_event = StreamEvent(
- type=StreamEventType.DONE,
- source=capability_name,
- metadata={"status": "completed"},
- )
- await self._publish_live_event(execution, pending_done_event)
- stream_done_sent = True
except asyncio.CancelledError:
if not stream_done_sent:
await self._publish_live_event(
diff --git a/tests/api/test_unified_ws_turn_runtime.py b/tests/api/test_unified_ws_turn_runtime.py
index e7e9c9916..183a9fbea 100644
--- a/tests/api/test_unified_ws_turn_runtime.py
+++ b/tests/api/test_unified_ws_turn_runtime.py
@@ -81,9 +81,11 @@ async def test_turn_runtime_replays_events_and_materializes_messages(
store = SQLiteSessionStore(tmp_path / "chat_history.db")
runtime = TurnRuntimeManager(store)
captured: dict[str, object] = {}
+ publish_order: list[str] = []
original_publish = runtime._publish_live_event
async def publish_with_status_capture(execution, event):
+ publish_order.append(event.type.value)
if event.type == StreamEventType.DONE:
persisted_turn = await store.get_turn(execution.turn_id)
captured["turn_status_when_done_published"] = (persisted_turn or {}).get("status")
@@ -91,6 +93,11 @@ async def test_turn_runtime_replays_events_and_materializes_messages(
monkeypatch.setattr(runtime, "_publish_live_event", publish_with_status_capture)
+ async def title_after_done(*_args, **_kwargs):
+ captured["title_started_after_done"] = "done" in publish_order
+
+ monkeypatch.setattr(runtime, "_maybe_generate_session_title", title_after_done)
+
class FakeContextBuilder:
def __init__(self, *_args, **_kwargs) -> None:
pass
@@ -188,6 +195,7 @@ async def test_turn_runtime_replays_events_and_materializes_messages(
done_event = next(e for e in events if e["type"] == "done")
assert done_event["metadata"]["status"] == "completed"
assert captured["turn_status_when_done_published"] == "completed"
+ assert captured["title_started_after_done"] is True
detail = await store.get_session_with_messages(session["id"])
assert detail is not None