{"record":{"id":"eb9f14841857c1e0","repo":"microsoft/autogen","slug":"no-stop-reason-found","errorCode":null,"errorMessage":"No stop reason found","messagePattern":"No stop reason found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py","lineNumber":558,"sourceCode":"            if choice and choice.delta.tool_calls is not None:\n                for tool_call_chunk in choice.delta.tool_calls:\n                    # print(tool_call_chunk)\n                    if \"index\" in tool_call_chunk:\n                        idx = tool_call_chunk[\"index\"]\n                    else:\n                        idx = tool_call_chunk.id\n                    if idx not in full_tool_calls:\n                        full_tool_calls[idx] = FunctionCall(id=\"\", arguments=\"\", name=\"\")\n\n                    full_tool_calls[idx].id += tool_call_chunk.id\n                    full_tool_calls[idx].name += tool_call_chunk.function.name\n                    full_tool_calls[idx].arguments += tool_call_chunk.function.arguments\n\n        if chunk and chunk.usage:\n            prompt_tokens = chunk.usage.prompt_tokens\n\n        if finish_reason is None:\n            raise ValueError(\"No stop reason found\")\n\n        content: Union[str, List[FunctionCall]]\n\n        if len(content_deltas) > 1:\n            content = \"\".join(content_deltas)\n            if chunk and chunk.usage:\n                completion_tokens = chunk.usage.completion_tokens\n            else:\n                completion_tokens = 0\n        else:\n            content = list(full_tool_calls.values())\n\n            if len(content_deltas) > 0:\n                thought = \"\".join(content_deltas)\n\n        usage = RequestUsage(\n            completion_tokens=completion_tokens,\n            prompt_tokens=prompt_tokens,","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py#L540-L576","documentation":"Raised at the end of AzureAIChatCompletionClient.create_stream() when the entire streamed response finished without any chunk carrying a finish_reason (the local finish_reason variable stayed None). CreateResult requires a FinishReasons value, so the client fails instead of fabricating one. Typical causes are transport truncation (network drop, timeout, content filter aborting mid-stream) or a service bug where the terminal chunk is never delivered.","triggerScenarios":"Streaming a long generation that gets cut off (connection reset, gateway timeout at 60s/120s, proxy buffering limits); content_filter events that close the stream without a finish_reason; empty streams from misrouted deployments.","commonSituations":"Long completions behind corporate proxies or Azure Gateway with aggressive idle timeouts; intermittent networking during containerized runs; GitHub Models rate-limiting that terminates the SSE stream early.","solutions":["Wrap stream consumption in try/except ValueError('No stop reason found') and retry the request (optionally with smaller max_tokens to shorten the stream)","Increase/disable idle timeouts on proxies or HTTP client (e.g. httpx timeout config)","If reproducible with short prompts, capture the raw stream (autogen logging TRACE) and report — the service is closing without a terminal chunk"],"exampleFix":"# before\nasync for chunk in client.create_stream(msgs):\n    print(chunk)\n\n# after\nfor attempt in range(3):\n    try:\n        async for chunk in client.create_stream(msgs):\n            print(chunk)\n        break\n    except ValueError as e:\n        if \"No stop reason\" not in str(e) or attempt == 2:\n            raise","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(MAX_RETRIES):\n    try:\n        async for chunk in client.create_stream(msgs):\n            process(chunk)\n        break\n    except ValueError as e:\n        if \"No stop reason found\" not in str(e) or attempt == MAX_RETRIES - 1:\n            raise\n        await backoff(attempt)","preventionTips":["Bound max_tokens so streams finish well within proxy/gateway idle timeouts","Tune HTTP client timeouts for long streams","Retry once non-streaming when a stream ends without a finish reason"],"tags":["azure","streaming","truncated-response","network"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}