Skip to content

The agent that grows with you

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.py
index 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 False
await 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.py
index 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), which
report finish_reason correctly and were the source of #13971's
false-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 True
return provider_lower == "ollama"