DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(runtime): preserve incomplete capability terminal outcome
yepyhun029e1a3c22bf
diff --git a/deeptutor/runtime/orchestrator.py b/deeptutor/runtime/orchestrator.pyindex 7bf3cf51c..66e4bf614 100644--- a/deeptutor/runtime/orchestrator.py+++ b/deeptutor/runtime/orchestrator.py@@ -139,6 +139,22 @@ class ChatOrchestrator:terminal_error_metadata: dict[str, Any] = {}try:await capability.run(context, bus)+ if bus.result_completion is False:+ status = "failed"+ terminal_error_metadata = {+ "error_code": "capability_incomplete",+ "retryable": True,+ }+ await bus.error(+ "The requested operation did not complete. Please retry; "+ "previously saved work is preserved.",+ source=cap_name,+ metadata={+ "turn_terminal": True,+ "status": status,+ **terminal_error_metadata,+ },+ )except Exception as exc:status = "failed"logger.error("Capability %s failed: %s", cap_name, exc, exc_info=True)diff --git a/deeptutor/runtime/stream_bus.py b/deeptutor/runtime/stream_bus.pyindex 91a09cdd9..932eb1ef1 100644--- a/deeptutor/runtime/stream_bus.py+++ b/deeptutor/runtime/stream_bus.py@@ -59,6 +59,20 @@ class StreamBus:"""Largest sequence issued by this bus, or zero before its first event."""return self._next_seq - 1 if self._assign_seq else 0+ @property+ def result_completion(self) -> bool | None:+ """Read the final result's explicit completion claim, without mutable events.++ A normal return from a capability is not proof that its requested work+ completed. Older capabilities omit the field and retain their existing+ lifecycle. Nested/tool results are not capability RESULT events.+ """+ for event in reversed(self._history):+ if event.type == StreamEventType.RESULT:+ completed = event.metadata.get("completed")+ return completed if isinstance(completed, bool) else None+ return None+async def emit(self, event: StreamEvent) -> None:"""Push *event* to every active subscriber."""if self._closed: