fix(writer): 透传底层 LLM 错误详情(401 等)便于门禁定位
This commit is contained in:
@@ -88,3 +88,26 @@ def test_generate_chapter_with_async_engine():
|
||||
content = agent.generate_chapter(_ctx("db_design", "DB 設計"))
|
||||
assert content.chapter_id == "db_design"
|
||||
assert content.blocks and content.blocks[0].type == "paragraph"
|
||||
|
||||
|
||||
def test_generate_chapter_propagates_engine_error_detail():
|
||||
class FailingEngine:
|
||||
def chat_structured(self, *, session_id, prompt, variables, schema, retry_count=2):
|
||||
return SimpleNamespace(
|
||||
data={},
|
||||
status="failed",
|
||||
error="LLM HTTP 401: invalid key",
|
||||
error_code="LLM_NETWORK_ERROR",
|
||||
)
|
||||
|
||||
agent = WriterAgent(
|
||||
session_id="s",
|
||||
engine=FailingEngine(),
|
||||
prompt_registry=FakePromptRegistry(),
|
||||
state=WriterState(["db_design"]),
|
||||
max_retries=1,
|
||||
)
|
||||
with pytest.raises(WriterGenerationError) as exc:
|
||||
agent.generate_chapter(_ctx("db_design", "DB 設計"))
|
||||
assert "LLM HTTP 401" in str(exc.value)
|
||||
assert "LLM_NETWORK_ERROR" in str(exc.value)
|
||||
|
||||
Reference in New Issue
Block a user