mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-05 09:58:45 +00:00
Separate leaked-call classification from retry handling so Context Doctor
can apply XML suppression, thought splitting, and log settings before the
history entry is saved. Keep rejected calls out of JSON repair and tool
dispatch; disabling XML suppression retains them only as thoughts.
Core still owns bounded retries and history insertion, defaults to {} when
the plugin is disabled, and clears replayable Responses output and pending
continuation state. Update plugin settings guidance and ownership docs.
Validation: 455 focused tests passed locally and in Docker's framework
runtime. Restarted the idle live app, verified health and actual extension
ordering, and found no startup error markers.
3.9 KiB
3.9 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.pyclassifies completed text once throughhelpers.extract_tools, then authorizes a complete candidate using the Responses turn map or lazily resolved Chat Completions prompt/MCP surface. Missing/empty/failed discovery rejects recovery. It records the decision inparams_temporary["leaked_tool_call"]for Context Doctor, retry handling and response logging; none reparses it. Native calls remain authoritative; quoted examples and multiple calls are never recovered.- Extensions receive mutable
result_datawithllm_resultand may setskip_default_processingafter fully handling the turn. _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. Native calls are complete only when every raw argument value is a JSON object; a synthesized envelope around malformed arguments does not qualify._15_tool_call_retry.pyhandles rejected/truncated leaked calls after Context Doctor can supply non-executable history inresult_data["tool_call_retry_response"]. Without a plugin override it uses{}. It inserts history once throughhist_add_ai_responsewith no replayable output items, emits a static counted warning, and skips dispatch. The original result remains available for diagnostics. Responses rejects clear the pending provider continuation after history insertion, retaining recorded response IDs while forcing the next turn to use the formatted local history. Earlier provider-truncation handling remains authoritative._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.pyretries reasoning-only turns: add an agent-facingfw.msg_reasoning_only.mdhistory warning with a separatefw.msg_reasoning_only_response.mduser notice, and count them through the stop-unusable-response-loop extension._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.