From f3283876243043d4cf6c07d805f744b91100ec65 Mon Sep 17 00:00:00 2001 From: Teo Date: Fri, 1 Nov 2024 22:02:53 -0600 Subject: [PATCH] feat(orfix(orchestrator): OrchestratorError to serialize `Exception` as `str` --- src/controlflow/events/orchestrator_events.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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):