DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(runtime): localize incomplete turn notices
Bingxi Zhao (Frank)3a3cb277c180
diff --git a/deeptutor/capabilities/prompts/en/turn_status.yaml b/deeptutor/capabilities/prompts/en/turn_status.yamlnew file mode 100644index 000000000..c92c499ae--- /dev/null+++ b/deeptutor/capabilities/prompts/en/turn_status.yaml@@ -0,0 +1,2 @@+notices:+ capability_incomplete: "The requested operation did not complete. Please retry; previously saved work is preserved."diff --git a/deeptutor/capabilities/prompts/zh/turn_status.yaml b/deeptutor/capabilities/prompts/zh/turn_status.yamlnew file mode 100644index 000000000..7f6362437--- /dev/null+++ b/deeptutor/capabilities/prompts/zh/turn_status.yaml@@ -0,0 +1,2 @@+notices:+ capability_incomplete: "请求的操作未完成,请重试。之前保存的内容已保留。"diff --git a/deeptutor/runtime/orchestrator.py b/deeptutor/runtime/orchestrator.pyindex 66e4bf614..3253a79ec 100644--- a/deeptutor/runtime/orchestrator.py+++ b/deeptutor/runtime/orchestrator.py@@ -21,6 +21,8 @@ from deeptutor.events.event_bus import Event, EventType, get_event_busfrom deeptutor.runtime.registry.capability_registry import get_capability_registryfrom deeptutor.runtime.registry.tool_registry import get_tool_registryfrom deeptutor.runtime.stream_bus import StreamBus, register_bus, unregister_bus+from deeptutor.services.prompt.lookup import prompt_text+from deeptutor.services.prompt.manager import get_prompt_managerlogger = logging.getLogger(__name__)@@ -145,9 +147,11 @@ class ChatOrchestrator:"error_code": "capability_incomplete","retryable": True,}+ prompts = get_prompt_manager().load_prompts(+ "capabilities", "turn_status", language=context.language+ )await bus.error(- "The requested operation did not complete. Please retry; "- "previously saved work is preserved.",+ prompt_text(prompts, ("notices", "capability_incomplete")),source=cap_name,metadata={"turn_terminal": True,diff --git a/tests/runtime/test_orchestrator.py b/tests/runtime/test_orchestrator.pyindex d04a3d12d..41d8604c8 100644--- a/tests/runtime/test_orchestrator.py+++ b/tests/runtime/test_orchestrator.py@@ -179,7 +179,16 @@ class TestOrchestratorErrorHandling:@pytest.mark.asyncio@pytest.mark.parametrize("completed", [False, True, None])- async def test_explicit_incomplete_result_controls_terminal_status(self, completed):+ @pytest.mark.parametrize(+ "language, notice",+ [+ ("en", "The requested operation did not complete"),+ ("zh", "请求的操作未完成"),+ ],+ )+ async def test_explicit_incomplete_result_controls_terminal_status(+ self, completed, language, notice+ ):class ResultCapability:async def run(self, _context, bus):payload = {"response": "The requested operation was not delivered."}@@ -188,7 +197,9 @@ class TestOrchestratorErrorHandling:await bus.result(payload, source="chat")orch = _make_orchestrator({"chat": ResultCapability()})- events = [e async for e in orch.handle(UnifiedContext(user_message="practice"))]+ events = [+ e async for e in orch.handle(UnifiedContext(user_message="practice", language=language))+ ]done = next(e for e in events if e.type == StreamEventType.DONE)if completed is False:assert done.metadata["status"] == "failed"@@ -196,13 +207,16 @@ class TestOrchestratorErrorHandling:assert done.metadata["retryable"] is Trueerror = next(e for e in events if e.type == StreamEventType.ERROR)assert error.metadata["turn_terminal"] is True+ assert notice in error.contentfrom deeptutor.services.session._turn_runtime_shared import (_resolve_turn_failure_metadata,_resolve_turn_outcome,)+persisted = [{"type": e.type.value, "content": e.content, "metadata": e.metadata}- for e in events if e is not done+ for e in events+ if e is not done]assert _resolve_turn_outcome(persisted, done)[0] == "failed"assert _resolve_turn_failure_metadata(persisted) == ("capability_incomplete", True)