Prefer fuller Ollama analysis text

This commit is contained in:
OpenClaw Agent
2026-07-10 11:28:09 +00:00
parent 6ec28d33a4
commit 27f1d6a1e4

View File

@@ -458,12 +458,23 @@ def _extract_ollama_generated_text(resp_json: dict) -> str:
message.get("thinking"),
])
cleaned_candidates = []
for candidate in candidates:
if isinstance(candidate, str):
text = candidate.strip()
if "<think>" in text:
text = text.split("</think>")[-1].strip()
if text:
return text
return ""
cleaned_candidates.append(text)
if not cleaned_candidates:
return ""
usable = [text for text in cleaned_candidates if _analysis_text_is_usable(text)]
if usable:
return max(usable, key=len)
return max(cleaned_candidates, key=len)
def _analysis_text_is_usable(text: str) -> bool: