Skip to content

Commit f15513c

Browse files
committed
Surface model provider errors as run errors
Extend the existing model-error boundary beyond rate limits so known Bailian provider failures are emitted as AG-UI RUN_ERROR with original message text and optional diagnostic metadata. Constraint: Aone 83711637 asks model-side stream errors to surface as run errors instead of text messages. Rejected: status-code-only text promotion | generic assistant text can mention HTTP/status codes and must not terminate the stream. Rejected: broad provider error framework | the current PR only needs a compact SDK-side classifier for known Bailian model errors. Confidence: high Scope-risk: moderate Directive: Keep raw-text model-error patterns narrow; add negative tests whenever expanding provider text matching. Tested: uv run ruff check changed files; uv run pytest tests/unittests/server tests/unittests/integration => 781 passed, 2 skipped; uv run mypy --config-file mypy.ini . => 377 source files clean; independent code-reviewer APPROVE; architect WATCH with no blockers after heuristic tightening. Change-Id: Ibf1cbd9505b7064cbebd804383710fd7333455cd Not-tested: GitHub CI and MR review-comment readback are pending because push/comment touch shared remote state. Signed-off-by: congxiao.wxx <congxiao.wxx@alibaba-inc.com>
1 parent e666ee7 commit f15513c

9 files changed

Lines changed: 579 additions & 55 deletions

File tree

agentrun/integration/langgraph/agent_converter.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@
3030
from typing import Any, Dict, Iterator, List, Optional, Union
3131

3232
from agentrun.server.model import AgentResult, EventType
33-
from agentrun.utils.error_utils import (
34-
build_error_event_data,
35-
is_rate_limited_error,
36-
)
33+
from agentrun.utils.error_utils import build_error_event_data, is_model_error
3734
from agentrun.utils.log import logger
3835

3936
# 需要从工具输入中过滤掉的内部字段(LangGraph/MCP 注入的运行时对象)
@@ -961,7 +958,7 @@ def _convert_astream_events_event(
961958
fallback_code="LLM_ERROR",
962959
fallback_message=(
963960
error_message
964-
if is_rate_limited_error(error)
961+
if is_model_error(error)
965962
else f"LLM error: {error_message}"
966963
),
967964
),

agentrun/server/agui_protocol.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@
5353
# ============================================================================
5454

5555
DEFAULT_PREFIX = "/ag-ui/agent"
56-
RUN_ERROR_EXTRA_FIELDS = ("retryable", "retryAfterMs", "traceId")
56+
RUN_ERROR_EXTRA_FIELDS = (
57+
"retryable",
58+
"retryAfterMs",
59+
"traceId",
60+
"requestId",
61+
"statusCode",
62+
"providerCode",
63+
)
5764

5865

5966
@dataclass

agentrun/server/invoker.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@
2424
)
2525
import uuid
2626

27-
from agentrun.utils.error_utils import (
28-
build_error_event_data,
29-
is_rate_limited_error,
30-
)
27+
from agentrun.utils.error_utils import build_error_event_data, is_model_error
28+
from agentrun.utils.reasoning import get_reasoning_content
29+
3130
from .model import AgentEvent, AgentRequest, EventType
3231
from .protocol import (
3332
AsyncInvokeAgentHandler,
3433
InvokeAgentHandler,
3534
SyncInvokeAgentHandler,
3635
)
37-
from agentrun.utils.reasoning import get_reasoning_content
3836

3937

4038
class AgentInvoker:
@@ -343,7 +341,7 @@ def _wrap_model_chunk(self, item: Any) -> List[AgentEvent]:
343341
return events
344342

345343
def _wrap_text(self, text: str) -> AgentEvent:
346-
if is_rate_limited_error(text):
344+
if is_model_error(text):
347345
return AgentEvent(
348346
event=EventType.ERROR,
349347
data=build_error_event_data(

0 commit comments

Comments
 (0)