core/agent: add ErrorEvent and CancelledEvent

This commit is contained in:
2026-07-14 22:11:25 +08:00
parent 665c3f435d
commit b83e7bffc0
2 changed files with 19 additions and 1 deletions
+2
View File
@@ -2,6 +2,8 @@ from .chat import ChatAgent as ChatAgent
from .client import ChatClient as ChatClient
from .events import AgentEvent as AgentEvent
from .events import AssistantMessageEvent as AssistantMessageEvent
from .events import CancelledEvent as CancelledEvent
from .events import ErrorEvent as ErrorEvent
from .events import MaxRoundsEvent as MaxRoundsEvent
from .events import TextDeltaEvent as TextDeltaEvent
from .events import ToolCallEvent as ToolCallEvent
+17 -1
View File
@@ -28,4 +28,20 @@ class MaxRoundsEvent(Struct, tag_field="type", tag="max_rounds"):
continued: bool = False
type AgentEvent = TextDeltaEvent | AssistantMessageEvent | ToolCallEvent | ToolResultEvent | MaxRoundsEvent
class ErrorEvent(Struct, tag_field="type", tag="error"):
message: str
class CancelledEvent(Struct, tag_field="type", tag="cancelled"):
pass
type AgentEvent = (
TextDeltaEvent
| AssistantMessageEvent
| ToolCallEvent
| ToolResultEvent
| MaxRoundsEvent
| ErrorEvent
| CancelledEvent
)