datawhalechina/hello-agents · error · HelloAgentsException
流式工具调用失败: {str(e)}
Error message
流式工具调用失败: {str(e)} What it means
In enhanced_llm.py, the streaming tool-call loop wraps its entire body in try/except Exception and re-raises as HelloAgentsException('流式工具调用失败: ...'). The original exception text is preserved in the message, so the real cause is whatever the streaming SDK call raised: provider auth errors, rate limits, malformed tool-call deltas, network resets, or bugs in delta-handling code. Because the except swallows the type, callers cannot narrow on the original exception class.
Source
Thrown at Co-creation-projects/tino-chen-HelloClaw/src/agent/enhanced_llm.py:236
if tc_delta.function and tc_delta.function.arguments:
args_delta = tc_delta.function.arguments
result.add_tool_call_delta(idx, args_delta)
yield StreamToolEvent(
event_type=StreamToolEventType.TOOL_CALL_DELTA,
tool_call_index=idx,
tool_arguments_delta=args_delta
)
# 处理结束原因
if choice.finish_reason:
result.finish_reason = choice.finish_reason
yield StreamToolEvent(
event_type=StreamToolEventType.FINISH,
finish_reason=choice.finish_reason
)
except Exception as e:
raise HelloAgentsException(f"流式工具调用失败: {str(e)}")
# 保存累积结果供后续使用
self._last_stream_tool_result = result
def get_last_stream_tool_result(self) -> Optional[StreamToolCallResult]:
"""
获取最后一次流式工具调用的累积结果
Returns:
StreamToolCallResult 或 None
"""
return self._last_stream_tool_result
View on GitHub (pinned to 606a07d341)
Solutions
- Read the wrapped text — it contains the provider/SDK error verbatim; fix that first (key, quota, model name, base_url).
- Retry with exponential backoff for transient 429/5xx/network-reset causes; make the retry re-open the stream, not resume it.
- Pin compatible SDK versions (openai/hello-agents) if the message shows AttributeError/KeyError on chunk fields.
- Increase the client read timeout for long tool-call generations.
- Change the wrapper to `raise HelloAgentsException(...) from e` so the traceback retains the original exception for diagnosis.
Example fix
# before
except Exception as e:
raise HelloAgentsException(f"流式工具调用失败: {str(e)}")
# after
except Exception as e:
raise HelloAgentsException(f"流式工具调用失败: {str(e)}") from e # keeps original traceback Defensive patterns
Strategy: retry
Validate before calling
import os
required = ["LLM_API_KEY"] # adjust to this deployment's env names
missing = [k for k in required if not os.getenv(k)]
if missing:
raise SystemExit(f"missing env: {missing}") Try / catch
from hello_agents import HelloAgentsException
import time
for attempt in range(3):
try:
result = consume_stream(llm.stream_tool_call(...))
break
except HelloAgentsException as e:
msg = str(e)
if any(t in msg for t in ("429", "rate", "timeout", "reset")) and attempt < 2:
time.sleep(2 ** attempt) # transient — back off and re-open the stream
continue
raise # auth/validation errors are not retryable Prevention
- Retry only transient causes (429/5xx/reset) and always re-open the stream
- Set generous read timeouts for long tool-call streams
- Upgrade hello-agents and the provider SDK together, pinned in requirements
- Log the wrapped message verbatim — it contains the real provider error
When it happens
Trigger: Invalid/expired API key when the stream request is opened; HTTP 429/5xx from the provider mid-stream; tool_calls deltas arriving in an order the accumulation logic does not expect (index/id None); connection reset or read timeout while yielding chunks; an SDK version change in the stream chunk schema causing AttributeError inside the loop.
Common situations: Long streaming sessions hitting provider timeouts; switching LLM providers/base_url without updating SDK assumptions; concurrent streams exceeding rate limits; hello-agents/OpenAI SDK version mismatch after upgrade.
Related errors
- 服务响应中断,请重试
- 工具 '{tool_name}' 执行超时
- Hunter Agent执行失败: {str(e)}
- ArXiv API请求失败: {response.status}
- IEEE API请求失败: {response.status}
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/c69be86f2fe1dfe1.
Report an issue: GitHub.