fix(agent): exempt :cloud GLM models from stop->length truncation rewrite
Ollama cloud models (model name contains ':cloud') run generation on Ollama's hosted server; the local 11434 endpoint is only a transparent proxy that forwards finish_reason faithfully. _is_ollama_glm_backend() was matching these models because the proxy listens on the same port as local Ollama, causing _should_treat_stop_as_truncated() to rewrite a correct finish_reason='stop' into 'length'. The 4-attempt continuation loop then injects a synthetic user nudge that reasoning-capable GLM models spend their output budget deliberating over, producing unpunctuated tails that re-trigger _has_natural_response_ending() rejection -- a self-reinforcing loop that always exhausts retries. Fix: add an early return in _is_ollama_glm_backend when the model name contains ':cloud'. Local GLM inference (no ':cloud') is still caught by the existing port/URL/provider checks. Fixes #98406
This commit is contained in:
16
run_agent.py
16
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
|
||||
|
||||
Reference in New Issue
Block a user