Repository navigation
fix(ga): match truncation markers only at tail, not anywhere in last N chars - #872
Closed
leonsong09 wants to merge 1 commit into
Closed
leonsong09 wants to merge 1 commit into
leonsong09 wants to merge 1 commit into
Conversation
…N chars do_no_tool() decided "incomplete response" whenever a truncation marker appeared anywhere in the trailing window of the reply. If the model quotes such a marker in its own text (debugging this very check, writing docs, or writing a test), the whole reply is discarded and replaced with "[ERROR] Incomplete response. Regenerate and tooluse." -- the user sees the answer stop mid-way and restart, and after 3 attempts the task aborts. llmcore appends these markers at the very end of the response, so an end-anchored match is both sufficient and precise. Changes: - match markers of form "[!!! 流异常中断 ... !!!]", "[!!! Response truncated ... !!!]" and "[!!! output truncated ... !!!]" only when they terminate the content. Previously only the first kind was checked at all, so genuinely truncated responses could slip through. - "!!!Error:" matched at start/end instead of "anywhere in window" - "max_tokens !!!]" matched at end Verified end-to-end against do_no_tool with 9 cases: body references are now accepted; real tail markers (including markers that themselves contain a bracket, e.g. "(no [DONE])") are still rejected.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GenericAgentHandler.do_no_tool()reports an incomplete response whenever a truncation marker appears anywhere in the trailing window of the reply:If the model quotes such a marker in its own text — which happens naturally when it is debugging this very check, writing documentation about truncation handling, or writing a regression test — the whole reply is discarded and replaced with:
The user sees the answer stop mid-way and restart, and after 3 attempts
_retry_or_exitaborts the task. This is a self-triggering false positive: the more the model explains the mechanism, the more likely it is to trip it.Fix
llmcorealways appends these markers at the very end of the response, so anchoring the match to the end is both sufficient and precise.While touching this, two markers that
llmcoreactually emits were not checked at all and are now covered:[!!! Response truncated: max_tokens !!!](llmcore.py:245)[!!! output truncated: {reason}](llmcore.py:331, 444)!!!Error:is matched at start/end instead of "anywhere in window", andmax_tokens !!!]is matched at the end.Verification
End-to-end against
do_no_tool()with 9 cases (fake_retry_or_exit, generator drained,StopIteration.value.next_promptinspected):[DONE]Response truncated: max_tokensat tailoutput truncatedat tail<summary>, < 100 chars<summary>+ real body!!!Error:Note the marker often contains a bracket of its own, e.g.
[!!! 流异常中断,未收到完整响应(无 [DONE])!!!]. A naive[^\]]*pattern stops at the inner]and silently fails to detect genuine truncation —.*?up to!!!]is required. This was caught by the test, not by inspection.