Skip to content

The agent that grows with you

fix(agent): exempt :cloud GLM models from stop->length truncation rewrite

salch-credbbed304536a6
diff --git a/run_agent.py b/run_agent.py
index dd2641e7826..8d8789657e9 100644
--- a/run_agent.py
+++ b/run_agent.py
@@ -1886,17 +1886,23 @@ class AIAgent:
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).
+ Also excludes Ollama Cloud — the hosted service correctly reports
+ finish_reason and is not affected by the local Ollama stop-reason
+ bug (GH-72316). Two signatures identify it: the ``ollama.com`` host
+ (provider ``ollama-cloud``) and the ``:cloud`` model suffix (cloud
+ generation proxied through a local 11434 endpoint, #98406). Applying
+ the stop→length rewrite to them manufactures false truncations and
+ causes the continuation nudge to consume the model's output budget
+ on the next retry, making further false-positives more likely.
"""
model_lower = (self.model or "").lower()
provider_lower = (self.provider or "").lower()
if "glm" not in model_lower and provider_lower != "zai":
return False
base = self._base_url_lower
- # Exclude Ollama Cloud (ollama.com) — hosted service, not local Ollama
- if "ollama.com" in base:
+ # Ollama Cloud (hosted service or :cloud proxy) forwards finish_reason
+ # faithfully — do not rewrite.
+ if "ollama.com" in base or ":cloud" in model_lower:
return False
if "ollama" in base or ":11434" in base:
return True