From e69032ea90c0475486fff5fdead3fb32842f208a Mon Sep 17 00:00:00 2001 From: dappweb Date: Fri, 28 Aug 2026 20:16:32 +0800 Subject: [PATCH] compat: treat natural no_tool finish as a complete run Two parity gaps for OpenAI-compatible models that end a task with a plain-text answer instead of a final tool call (observed with Qwen3.5-based local endpoints): 1. workflows/stateful_react_agent/_runtime.py: _GRACEFUL_FINAL_STOP_ REASONS does not include "no_tool", so force_final_answer() rescue is skipped even though the model produced its answer and the loop ended naturally. 2. apodex/task_runner.py: the native-workflow path calls _is_complete_ run() without no_tool_is_complete=True, unlike the generic loop path (L396), so the same natural finish is reported as "run incomplete" and the report is not saved. With both applied, a local qwen3.8-27b endpoint completes the stateful react workflow end to end and the final report is saved. --- apodex/task_runner.py | 1 + workflows/stateful_react_agent/_runtime.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apodex/task_runner.py b/apodex/task_runner.py index 1ccb527..7df00f7 100644 --- a/apodex/task_runner.py +++ b/apodex/task_runner.py @@ -564,6 +564,7 @@ async def _run_native_workflow(self, task: str, profile: Any) -> None: stopped_by, answer_status=str(state.get("answer_status") or ""), answer_source=str(state.get("final_answer_source") or ""), + no_tool_is_complete=True, ) if complete: self.r.final( diff --git a/workflows/stateful_react_agent/_runtime.py b/workflows/stateful_react_agent/_runtime.py index cdefcc0..08e1337 100644 --- a/workflows/stateful_react_agent/_runtime.py +++ b/workflows/stateful_react_agent/_runtime.py @@ -116,7 +116,7 @@ def render_system_prompt_notes( # mid-token. Without the rescue that fragment IS the answer — which is how a run # whose visible output was "The shell ate my `" scored zero. _GRACEFUL_FINAL_STOP_REASONS = frozenset({ - "max_turns", "context_limit_reached", "response_truncated", + "max_turns", "context_limit_reached", "response_truncated", "no_tool", }) # Abnormal / infra terminations: the LLM endpoint exhausted retries