diff --git a/src/controlflow/agents/agent.py b/src/controlflow/agents/agent.py index ef1be609..e14ee063 100644 --- a/src/controlflow/agents/agent.py +++ b/src/controlflow/agents/agent.py @@ -238,7 +238,7 @@ async def run_async( objective: str, *, turn_strategy: Optional["TurnStrategy"] = None, - handlers: Optional[list["Handler"]] = None, + handlers: Optional[list[Union["Handler", "AsyncHandler"]]] = None, **task_kwargs, ): return await controlflow.run_async( diff --git a/src/controlflow/events/orchestrator_events.py b/src/controlflow/events/orchestrator_events.py index 6c07fef1..932fe8de 100644 --- a/src/controlflow/events/orchestrator_events.py +++ b/src/controlflow/events/orchestrator_events.py @@ -1,4 +1,7 @@ -from typing import Literal +from dataclasses import Field +from typing import Annotated, Literal + +from pydantic.functional_serializers import PlainSerializer from controlflow.agents.agent import Agent from controlflow.events.base import UnpersistedEvent @@ -21,7 +24,7 @@ class OrchestratorError(UnpersistedEvent): event: Literal["orchestrator-error"] = "orchestrator-error" persist: bool = False orchestrator: Orchestrator - error: Exception + error: Annotated[Exception, PlainSerializer(lambda x: str(x), return_type=str)] class AgentTurnStart(UnpersistedEvent):