Skip to content

Agent Zero AI framework

Count thoughts_fallback warning toward unusable-response limit

linkliti4a71f03768fd
diff --git a/extensions/python/_functions/agent/Agent/hist_add_warning/end/_90_stop_unusable_response_loop.py b/extensions/python/_functions/agent/Agent/hist_add_warning/end/_90_stop_unusable_response_loop.py
index 868e2df28..e28abfcf9 100644
--- a/extensions/python/_functions/agent/Agent/hist_add_warning/end/_90_stop_unusable_response_loop.py
+++ b/extensions/python/_functions/agent/Agent/hist_add_warning/end/_90_stop_unusable_response_loop.py
@@ -24,6 +24,7 @@ class StopUnusableResponseLoop(Extension):
self.agent.read_prompt("fw.msg_repeat.md"),
self.agent.read_prompt("fw.msg_empty_response.md"),
self.agent.read_prompt("fw.msg_reasoning_only.md"),
+ self.agent.read_prompt("fw.msg_thoughts_fallback.md"),
}:
return
diff --git a/plugins/_context_doctor/AGENTS.md b/plugins/_context_doctor/AGENTS.md
index 8a3bd7113..81cc873d5 100644
--- a/plugins/_context_doctor/AGENTS.md
+++ b/plugins/_context_doctor/AGENTS.md
@@ -18,7 +18,7 @@
- Repaired and fallback JSON is always minified.
- Nonempty non-tool output becomes `{"thoughts":[raw]}`; XML-like output becomes `{}` only when suppression is enabled.
- Blank-line-separated thoughts expand into separate entries after repair when the split strategy is enabled (default on).
-- A raw-text fallback conversion emits a `fw.msg_thoughts_fallback.md` history warning and a separate `fw.msg_thoughts_fallback_response.md` user notice, refreshes the generating log and response item with the transformed thoughts JSON, then sets `skip_default_processing` so the retry advances the unusable-response counter. The warning prompts are plugin-owned and are not counted by the core stop-unusable-response loop.
+- A raw-text fallback conversion emits a `fw.msg_thoughts_fallback.md` history warning and a separate `fw.msg_thoughts_fallback_response.md` user notice, refreshes the generating log and response item with the transformed thoughts JSON, then sets `skip_default_processing` so the retry advances the unusable-response counter. The fallback warning is counted by the core stop-unusable-response loop alongside `fw.msg_misformat.md`, `fw.msg_repeat.md`, `fw.msg_empty_response.md`, and `fw.msg_reasoning_only.md`.
- Log kvps retain streamed `reasoning` and `thoughts`, then add transformed output; `update_log` controls only View Details content.
- A repaired `response` tool call refreshes the response log item when streaming did not create it.
- Runtime setup reads the `json_repair` pin from root `requirements.txt`; do not duplicate its version in plugin code.
diff --git a/tests/test_unusable_response_loop.py b/tests/test_unusable_response_loop.py
index 83bc19322..51c46d26f 100644
--- a/tests/test_unusable_response_loop.py
+++ b/tests/test_unusable_response_loop.py
@@ -101,6 +101,21 @@ def test_reasoning_only_warning_counts_toward_the_limit(monkeypatch):
assert agent.loop_data.params_persistent[response_loop.STATE_KEY]["count"] == 1
+def test_thoughts_fallback_warning_counts_toward_the_limit(monkeypatch):
+ monkeypatch.setattr(
+ response_loop,
+ "get_settings",
+ lambda: {"max_consecutive_unusable_responses": 1},
+ )
+ agent = _agent()
+ extension = response_loop.StopUnusableResponseLoop(agent=agent)
+
+ data = _run(extension, agent, "thoughts fallback")
+
+ assert isinstance(data["exception"], HandledException)
+ assert agent.loop_data.params_persistent[response_loop.STATE_KEY]["count"] == 1
+
+
def test_general_settings_expose_the_default_failure_limit():
settings = get_default_settings()
assert settings["max_consecutive_unusable_responses"] == 5