The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): exclude Ollama Cloud from GLM truncation detection; propagate partial flag (#72316)
JonthanaHanh5360886f54b6
diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.pyindex 004ef1a9e1e..33c77eaa688 100644--- a/gateway/platforms/api_server.py+++ b/gateway/platforms/api_server.py@@ -4993,12 +4993,13 @@ class APIServerAdapter(BasePlatformAdapter):else ""),)+ is_partial = bool(result.get("partial")) if isinstance(result, dict) else Falseawait queue.put(_event_payload("assistant.completed", {"session_id": effective_session_id,"message_id": message_id,"content": final_response,"completed": True,- "partial": False,+ "partial": is_partial,"interrupted": False,"runtime": effective_runtime,}))diff --git a/run_agent.py b/run_agent.pyindex eb904ccc711..dd2641e7826 100644--- a/run_agent.py+++ b/run_agent.py@@ -1885,12 +1885,20 @@ class AIAgent:(LiteLLM/sglang/vLLM/LM Studio proxies, Tailscale boxes), whichreport finish_reason correctly and were the source of #13971'sfalse-positive truncation continuations.++ Also excludes Ollama Cloud (ollama.com) — the hosted service+ correctly reports finish_reason and is not affected by the local+ Ollama stop-reason bug (GH-72316)."""model_lower = (self.model or "").lower()provider_lower = (self.provider or "").lower()if "glm" not in model_lower and provider_lower != "zai":return False- if "ollama" in self._base_url_lower or ":11434" in self._base_url_lower:+ base = self._base_url_lower+ # Exclude Ollama Cloud (ollama.com) — hosted service, not local Ollama+ if "ollama.com" in base:+ return False+ if "ollama" in base or ":11434" in base:return Truereturn provider_lower == "ollama"