File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
openhands-sdk/openhands/sdk Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 2323 PauseEvent ,
2424 UserRejectObservation ,
2525)
26+ from openhands .sdk .event .conversation_error import ConversationErrorEvent
2627from openhands .sdk .llm import LLM , Message , TextContent
2728from openhands .sdk .llm .llm_registry import LLMRegistry
2829from openhands .sdk .logger import get_logger
@@ -312,6 +313,16 @@ def run(self) -> None:
312313 break
313314 except Exception as e :
314315 self ._state .execution_status = ConversationExecutionStatus .ERROR
316+
317+ # Add an error event
318+ self ._on_event (
319+ ConversationErrorEvent (
320+ source = "environment" ,
321+ code = e .__class__ .__name__ ,
322+ detail = str (e ),
323+ )
324+ )
325+
315326 # Re-raise with conversation id for better UX; include original traceback
316327 raise ConversationRunError (self ._state .id , e ) from e
317328 finally :
Original file line number Diff line number Diff line change 1+ from pydantic import Field
2+
3+ from openhands .sdk .event .base import Event
4+
5+
6+ class ConversationErrorEvent (Event ):
7+ """
8+ Conversation-level failure that is NOT sent back to the LLM.
9+
10+ This event is emitted by the conversation runtime when an unexpected
11+ exception bubbles up and prevents the run loop from continuing. It is
12+ intended for client applications (e.g., UIs) to present a top-level error
13+ state, and for orchestration to react. It is not an observation and it is
14+ not LLM-convertible.
15+
16+ Differences from AgentErrorEvent:
17+ - Not tied to any tool_name/tool_call_id (AgentErrorEvent is a tool
18+ observation).
19+ - Typically source='environment' and the run loop moves to an ERROR state,
20+ while AgentErrorEvent has source='agent' and the conversation can
21+ continue.
22+ """
23+
24+ code : str = Field (description = "Code for the error - typically a type" )
25+ detail : str = Field (description = "Details about the error" )
You can’t perform that action at this time.
0 commit comments