From 13abe544c868763636642543827cdef82a816a2f Mon Sep 17 00:00:00 2001 From: piglei Date: Mon, 13 Apr 2026 23:19:49 +0800 Subject: [PATCH] fix: type error when constructing RepublicError on error --- src/bub/framework.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bub/framework.py b/src/bub/framework.py index 85cbb6ed..005f2221 100644 --- a/src/bub/framework.py +++ b/src/bub/framework.py @@ -11,6 +11,7 @@ from dotenv import load_dotenv from loguru import logger from republic import AsyncTapeStore, RepublicError, TapeContext +from republic.core.errors import ErrorKind from republic.tape import TapeStore from bub.envelope import content_of, field_of, unpack_batch @@ -146,8 +147,13 @@ async def _run_model( if event.kind == "text": parts.append(str(event.data.get("delta", ""))) elif event.kind == "error": + # Turn "kind" to enum type otherwise the RepublicError's __str__ won't work well + data = { + **event.data, + "kind": ErrorKind(event.data.get("kind", "unknown")), + } await self._hook_runtime.notify_error( - stage="run_model", error=RepublicError(**event.data), message=inbound + stage="run_model", error=RepublicError(**data), message=inbound ) return "".join(parts)