mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 09:28:56 +00:00
Recovered turns showed no hint that the reply was kept as thoughts and retried, because earlier notices had been silenced and the new non-action prose branch logged none. The notices return as utility rows following the Show utility messages preference and carry the warning message id so they stay attached to their history warning. Both plain-text rows share one wording adapted from the pre-silence fallback prompt, following the surviving fw.msg_reasoning_only_response.md pattern and the recovery-notice sync contract that keeps the core and plugin rows identical. Validation: pytest tests/test_message_loop_result.py plugins/_context_doctor/tests/test_context_doctor.py tests/test_leaked_tool_call_integration.py tests/test_unusable_response_loop.py tests/test_plain_response_logging.py tests/test_responses_architecture.py tests/test_prompt_catalogs.py (7 failed, 327 passed in 9.28s; the failures reproduce identically on the base commit)
4.5 KiB
4.5 KiB
Message Loop Result Extensions DOX
Purpose
- Own normalization and policy handling after a model turn completes, before default assistant-history and tool-dispatch processing.
Ownership
_05_leaked_tool_call.pyoptionally converts complete alternate-format text throughhelpers.extract_toolsbefore Context Doctor. It maps aliases and normalizes actions against the Responses turn map or lazily resolved Chat Completions prompt/MCP surface. Failed conversion or unavailable tools leave the result untouched for normal repair and dispatch; this hook never inserts history, warns, or forces a retry. Native calls remain authoritative.- Extensions receive mutable
result_datawithllm_resultand may setskip_default_processingafter fully handling the turn. - Text converters preserve the first input in turn-local
result_data.raw_responsebefore rewriting it, so Context Doctor can keep original View Details content whenupdate_logis off. Recovery retains the outer call's string headline for display and emits autildiagnostic, following the WebUI's utility visibility preference. _05_truncated_response.pyretries turns the provider cut off at the output token limit (LLMResult.truncated) that carry no complete tool request: add an agent-facingfw.msg_output_limit.mdhistory warning with a separatefw.msg_output_limit_response.mduser notice naming the finish reason, instead of the generic misformat warning, and count them through the stop-unusable-response-loop extension. Reasoning-only output defers to thought-preserving recovery below. Native calls are complete only when every raw argument value is a JSON object; a synthesized envelope around malformed arguments does not qualify._20_empty_response.pyretries fully empty turns (no response and no reasoning): count them toward the unusable-response limit without adding a warning to model history, and usefw.msg_empty_response.mdfor the UI warning text only._20_empty_response.pyalso catches non-action prose in either transport when Context Doctor is disabled: retain assistant text in history, show it as thoughts on the generating log, append the internalfw.msg_misformat.mdreminder, and pair it with thefw.msg_misformat_response.mdnotice. Actual tool requests and unrepaired tool intent retain their dispatch/repair paths._20_empty_response.pyretries reasoning-only turns: append emitted reasoning as compact assistant thoughts throughhist_add_ai_response, preserve the originalLLMResultmetadata and Responses state, and display thoughts on the existing generation log. Append the internalfw.msg_reasoning_only.mdreminder and pair it with thefw.msg_reasoning_only_response.mdnotice; it still advances the stop-unusable-response counter. Native function/built-in actions bypass this handler.- Recovery notices in
_20_empty_response.pylog asutilrows carrying the warning message id, so they follow the WebUI preference and stay hidden until the user enables utility messages. Empty-turn and stop notices keepwarningrows, which are always visible. _30_repeat_response.pycomparesLLMResult.repeat_response_text()for native calls (public text plus all calls), otherwise full response text. It retries content that exactly matchesloop_data.last_response, regardless of separate reasoning or provider IDs, usingfw.msg_repeat.mdfor history andfw.msg_repeat_response.mdfor the UI warning text. State advancement is owned byhist_add_ai_response; do not call_remember_llm_result_statemanually._40_native_thoughts.pyfolds public commentary accompanying native function calls into the existing completed-generation logthoughtsarray. It preserves provider output items, canonical history, repeat comparison and dispatch. It respects handled results and excludes reasoning/encrypted items and explicit final-answer messages. Normal log masking applies.
Local Contracts
- Files run in deterministic filename order.
- A handler that sets
skip_default_processingowns needed history and UI side effects for that turn. - Handlers that should not add side effects after an earlier extension has handled the result must return when
skip_default_processingis set. - Do not use this point to mutate streamed partial content.
Work Guidance
- Normalize a completed result before policy extensions compare or persist it.
- Keep loop-control policy independent from optional plugins.
Verification
- Run message-loop and unusable-response regression tests.
Child DOX Index
No child DOX files.