Preserve free text and reasoning-only output in the current generation
and retry without intermediate warning rows. Require an explicit response
tool call to finish in both API modes, including after provider built-in
actions.
Keep history metadata, Responses state, tool validation and the
consecutive-failure stop intact. Allow core retries when Context Doctor
and its prompts are unavailable.
Validation: 411 backend tests and 2 Chromium live/replay grouping tests
passed; live runtime health check passed.
Keep the original model response in turn-local repair data so Context Doctor
honors Update log content: off retains raw XML/DSML in View Details, while
on shows repaired JSON. Mark successful recovery notices as utility messages
so they follow the existing UTL visibility preference.
Accept an outer headline alongside DSML tool_args and preserve it through
normalization. Keep parallel calls, nested arguments and command escaping
intact, with normal repair fallback and dispatch unchanged.
Add regression coverage for both transports, log-setting states, disabled
Context Doctor, repeated repair hooks and outer versus nested headlines.
Update the owning documentation and include the reported DSML fixture.
Validation: 263 focused tests passed locally and in the Docker framework
runtime. The live instance restarted successfully and its health check passed.
Let unconverted alternate-format output reach Context Doctor's existing JSON
repair path. Remove the leaked-call rejection state, retry hook and prompts
so missing delimiters and other repairable output can execute in the same
turn, restoring the behavior from before PR #1920.
Keep complete XML/DSML/native-text conversion, normal tool permissions,
Context Doctor's XML history cleanup and existing output-limit handling.
Update integration tests and ownership documentation for the restored flow.
Validation: 504 targeted tests passed both locally and in the Docker framework
runtime, including actual agent-loop tests for missing brackets and braces.
Historical comparisons matched pre-PR behavior in 48 cases and confirmed
12 additive format-conversion cases. Restarted the local runtime and verified
its health and extension discovery.
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.
Recognize a standalone DSML calls/function_calls envelope containing one
invocation. Preserve explicitly string-valued parameters, strictly decode
JSON-valued parameters, and unwrap a sole object-valued tool_args field.
Keep canonical streaming parsing unchanged. Reject incomplete, malformed,
duplicate, mixed-wrapper, multiple-call, or prose-surrounded payloads;
quoted examples remain non-executable. Recovered calls still require an
offered tool and pass the normal execution-time permission checks.
Validation: 378 focused tests passed locally and in Docker's framework
runtime, including the reported DSML command as parser-only test data,
Chat Completions/Responses dispatch, and blocked-tool enforcement.
Store a neutral {} for rejected or incomplete leaked calls so retries do
not reinforce malformed XML or JSON. Keep the original result available
for diagnostics and preserve the existing warning and retry limits.
Remove replayable output items from the history copy and clear the
Responses continuation after normal history insertion. Retain recorded
turn IDs and usage while forcing the next request to use cleaned history.
This works with Context Doctor enabled or disabled.
Validation: 349 focused parser, dispatch, history, Responses, streaming,
Context Doctor, and retry-limit tests passed for this standalone change.
Framework warning log rows no longer repeat the agent name before the message text, covering tool and execution errors, the misformat notice, and the truncated, empty, repeat and fallback response warnings. A source-level regression test keeps the warning rows prefix-free, and the message-loop and context-doctor DOX and tests stop expecting the removed prefix.
Validation: pytest tests/test_warning_log_prefixes.py tests/test_tool_action_contracts.py tests/test_message_loop_result.py plugins/_context_doctor/tests/test_context_doctor.py
Record the Chat Completions finish_reason on LLMResult and add a
message_loop_result extension that, when a turn stopped at the output
token limit (finish_reason "length"/"max_tokens") without a complete
tool request, retries with a warning naming truncation as the cause
rather than the generic misformat message. The warning counts toward
the existing unusable-response loop limit.
Context Doctor now leaves results already handled by an earlier
extension untouched, so truncated envelopes are not repaired and
dispatched with cut-off arguments.
Fixes#1836
Keep usable Responses output text intact in Context Doctor so core can
complete it through the normal response tool and policy path. Continue
repairing recognizable tool intent and retrying plain Chat Completions text.
Verified 100 focused tests and direct Docker framework dispatch. Live Codex
preset terminal tasks used native calls with 79% and 78% cache hits; the same
chat switched to Venice and completed its Chat Completions terminal task.
Leave canonical function calls and their accompanying text untouched by
text repair. Otherwise a valid native call with plain-text output can enter
the fallback branch and skip normal tool dispatch. Apply this to both
Responses and Chat Completions while retaining the existing execution
policy gate and text-only repair behavior.
Cover plain text, XML-like output, and a textual second call, including
metadata preservation and single native dispatch. Update the plugin
contract. All 144 focused tests pass; two live Codex OAuth terminal tasks
completed with final cache hits of 77% and 76% in the context viewer.
Move raw thoughts wrapping after repair selection so fallback warnings and retry handling run for plain text. Cover the Hello there… regression and align tool-args display assertions with response exclusion and reserved-key filtering.
Guard empty/whitespace LLM responses so context_doctor defers to _20_empty_response instead of polluting history with {thoughts:[]}. Require looks_like_tool_call to find at least one A0 key with a usable non-empty value (non-empty list of non-empty strings for thoughts, non-empty string for headline/tool_name, non-empty dict for tool_args). Update AGENTS.md contract and add regression tests for empty/blank/wrong-type rejections.
Add LLMResult.non_llm classmethod for non-LLM AI turns (greeting, intervention progress) so stored metadata does not claim a Responses-API turn. Rename is_thoughts_fallback to looks_like_tool_call (inverted polarity: True when valid A0 response JSON). Rework check to accept any dict containing at least one A0 key (thoughts/headline/tool_name/tool_args); empty dicts and non-A0 dicts fall through to the raw-text fallback branch. Fix drawMessageAgent kvps order to thoughts, tool_name, tool_args keys (reserved keys skipped), then step; reserved keys (thoughts, step, reasoning, tool_name, tool_args, args, headline) win over colliding tool_args keys. Document Hello! seeding turns as few-shot example, drawMessageDefault as deprecated, and plugin get_log_object duplication as intentional. Align context_doctor DOX kvps sentence with code (reasoning only, not thoughts).
Make llm_result required in hist_add_ai_response and move _remember_llm_result_state inside so plugin authors cannot silently break response_id chaining. Drop manual state calls in main loop and _30_repeat_response. Pass empty LLMResult() for greeting and intervention progress. Document invariant in root AGENTS.md and affected extension DOX.
Context Doctor's fw.msg_thoughts_fallback.md warning was excluded from the core stop-unusable-response loop allowlist, so consecutive plain-text fallbacks never advanced the counter. Add it alongside misformat, repeat, empty_response, and reasoning_only, update the plugin DOX, and cover the behavior with a regression test.
Fallback turns now refresh the generating log item kvps with the transformed thoughts JSON and preserved reasoning, matching the non-fallback path so View Details shows the repaired content. Add assertions covering kvps, reasoning retention, and raw content.
Context Doctor now persists the transformed thoughts JSON via hist_add_ai_response before emitting the fallback warning, matching the RepeatResponse retry pattern. Simplify is_thoughts_fallback to check tool_name absence so split multi-paragraph and native thoughts JSON are detected. Remove the core stop-unusable-response-loop counter for plugin-owned fallback warnings. Delete unreachable skip_default_processing block after the early fallback return.
Extracts value selection into _select_value helper, mutates _split_thoughts in place, and applies the split once after repair. Adds a split_thoughts config (default on) with a Strategies section in the plugin settings UI, regression tests for blank-line splitting in repaired JSON, raw-text fallback, and disabled mode. Keeps reasoning-only kvps retention and the raw-text fallback claim path.
Reasoning-only turns now retry with an agent-facing fw.msg_reasoning_only.md history warning and a separate fw.msg_reasoning_only_response.md user notice, counted by the stop-unusable-response-loop extension instead of falling through to the unclear misformat path. Context Doctor detects raw-text fallback conversions and claims the turn with fw.msg_thoughts_fallback.md agent warning and fw.msg_thoughts_fallback_response.md user notice, also counted by the stop loop. Both cases set skip_default_processing so the model gets a clear retry instruction.
Revert the stream-end copy of reasoning into thoughts, the context-doctor preservation of thoughts through log refresh, the related regression tests, and the AGENTS.md wording. thoughts is no longer auto-populated from reasoning when absent.
Promote native reasoning summaries after response streaming completes and keep the normalized thoughts through Context Doctor log refreshes. Add regression coverage for both lifecycle boundaries.
Read the pinned json_repair requirement from the root requirements file and install it into the active framework interpreter when the package is missing or stale.
Invoke the plugin hook during startup migration so self-updated installations converge without rebuilding the image.
Add focused coverage for version checks, install command construction, and startup dispatch.
After repair, return a recovered JSON object that already contains thoughts or headline as compact JSON instead of wrapping the raw response in another thoughts envelope.
Repair completed non-tool output into compact thoughts JSON, preserve schema-guided selection of the most complete repaired tool call, refresh log fields, and create a response log only for response tool calls using text. Suppress XML-shaped malformed responses as configured.
Cover raw fallback, repaired-call selection, and response-log handling.
Repair malformed Agent Zero tool-call JSON before default dispatch, then persist repaired compact response in WebUI log. Pin json_repair, retain targeted installed-parser patch, and expose XML suppression and log-detail settings.