You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -295,6 +295,53 @@ class MinimalProgressVisualizer(ConversationVisualizer):
295
295
296
296
**When to use**: When you need completely different output format, custom state tracking, or integration with external systems.
297
297
298
+
### Approach 3: Custom Object with on_event Method
299
+
300
+
You can implement custom visualizers without subclassing by creating any object with an `on_event` method. The conversation system only requires that your visualizer has this method:
301
+
302
+
```python
303
+
from rich.console import Console
304
+
from rich.panel import Panel
305
+
from openhands.sdk.event import Event
306
+
307
+
classCustomVisualizer:
308
+
"""Custom visualizer without subclassing ConversationVisualizer."""
309
+
310
+
def__init__(self):
311
+
self.event_count =0
312
+
self.console = Console()
313
+
314
+
defon_event(self, event: Event) -> None:
315
+
"""Handle any event - this is the only required method."""
visualize=CustomVisualizer() # Pass your custom object
335
+
)
336
+
```
337
+
338
+
**Key Requirements:**
339
+
- Must have an `on_event(self, event: Event) -> None` method
340
+
- Can be any Python object (class instance, function with state, etc.)
341
+
- No inheritance required
342
+
343
+
**When to use**: When you want maximum flexibility without inheriting from ConversationVisualizer, or when integrating with existing class hierarchies.
344
+
298
345
## Key Event Types
299
346
300
347
Understanding the event system is crucial for effective custom visualizers. Here's a comprehensive overview of all event types handled by the default visualizer:
@@ -314,68 +361,143 @@ Understanding the event system is crucial for effective custom visualizers. Here
314
361
### ActionEvent
315
362
Fired when the agent decides to use a tool or take an action.
316
363
364
+
**Key Properties:**
365
+
-`thought`: Agent's reasoning before taking action (list of TextContent)
366
+
-`action`: The actual tool action (None if non-executable)
367
+
-`tool_name`: Name of the tool being called
368
+
-`tool_call_id`: Unique identifier for the tool call
369
+
-`security_risk`: LLM's assessment of action safety
370
+
-`reasoning_content`: Intermediate reasoning from reasoning models
371
+
372
+
**Default Rendering:** Blue panel titled "Agent Action" showing reasoning, thought process, and action details.
0 commit comments