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,13 +458,24 @@ def _extract_ollama_generated_text(resp_json: dict) -> str:
message.get("thinking"), message.get("thinking"),
]) ])
cleaned_candidates = []
for candidate in candidates: for candidate in candidates:
if isinstance(candidate, str): if isinstance(candidate, str):
text = candidate.strip() text = candidate.strip()
if "<think>" in text:
text = text.split("</think>")[-1].strip()
if text: if text:
return text cleaned_candidates.append(text)
if not cleaned_candidates:
return "" 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: def _analysis_text_is_usable(text: str) -> bool:
text = (text or "").strip() text = (text or "").strip()