Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

fix(providers): remove __module__ guards — classify all SDK-try exceptions

xf gong9d2caaf60daf
diff --git a/cubepi/providers/anthropic.py b/cubepi/providers/anthropic.py
index d120c18..6bde0d7 100644
--- a/cubepi/providers/anthropic.py
+++ b/cubepi/providers/anthropic.py
@@ -308,12 +308,7 @@ class AnthropicProvider(BaseProvider):
except Exception as _sdk_exc:
from cubepi.errors import classify_and_raise
- # Guard: only classify Anthropic SDK errors, not local
- # callback/processing exceptions (on_response, _handle_event,
- # _convert_response, _assemble_response).
- if type(_sdk_exc).__module__.startswith("anthropic"):
- classify_and_raise(_sdk_exc, model=model, messages=messages)
- raise
+ classify_and_raise(_sdk_exc, model=model, messages=messages)
except BaseException as e:
exc = e
diff --git a/cubepi/providers/openai.py b/cubepi/providers/openai.py
index 3afa5ad..2b87bda 100644
--- a/cubepi/providers/openai.py
+++ b/cubepi/providers/openai.py
@@ -510,17 +510,15 @@ class OpenAIProvider(BaseProvider):
except BaseException as e:
exc = e
# Classify SDK stream-level errors that the narrow create()
- # try/except didn't catch. Only classify exceptions from the
- # openai SDK module — local callback/processing exceptions
- # (on_payload, on_response, assembly) must not be re-tagged.
+ # try/except didn't catch — async-for-chunk iteration errors
+ # (mid-stream connection drops, timeouts) arrive here raw.
if isinstance(e, Exception):
from cubepi.errors import classify_and_raise
- if type(e).__module__.startswith("openai"):
- try:
- classify_and_raise(e, model=model, messages=messages)
- except Exception as _classified:
- exc = _classified
+ try:
+ classify_and_raise(e, model=model, messages=messages)
+ except Exception as _classified:
+ exc = _classified
err_text = self._error_message(exc, model)
error_msg = AssistantMessage(
content=[],
diff --git a/cubepi/providers/openai_responses.py b/cubepi/providers/openai_responses.py
index 1fa7444..fac69e8 100644
--- a/cubepi/providers/openai_responses.py
+++ b/cubepi/providers/openai_responses.py
@@ -581,17 +581,15 @@ class OpenAIResponsesProvider(BaseProvider):
except BaseException as e:
exc = e
# Classify SDK stream-level errors that the narrow create()
- # try/except didn't catch. Only classify exceptions from the
- # openai SDK module — local callback/processing exceptions
- # must not be re-tagged.
+ # try/except didn't catch — async-for-event iteration errors
+ # arrive here raw.
if isinstance(e, Exception):
from cubepi.errors import classify_and_raise
- if type(e).__module__.startswith("openai"):
- try:
- classify_and_raise(e, model=model, messages=messages)
- except Exception as _classified:
- exc = _classified
+ try:
+ classify_and_raise(e, model=model, messages=messages)
+ except Exception as _classified:
+ exc = _classified
err_text = self._error_message(exc, model)
error_msg = AssistantMessage(
content=[],