Repository navigation
fix(agent): ask again when a coder response leaks function-call markup instead of ending the task - #1875
Merged
Conversation
…p instead of ending the task A coder-mode response whose tool call was written as invoke and parameter tags, or as a run of stray closers, carried no call chatcli recognizes. The loop took it for the final answer and printed task completed with the action never run, so a file the agent meant to write never existed. The response is now checked for that markup outside code fences and inline code, and when it is there the model is told that nothing was executed and shown the tool_call format, up to three times in a row. The markup is not converted into a call: text that only looks like one, quoted from a file or a tool result, must never run because it appeared in a response.
Contributor
Quality GateResult: ✅ all floors passed
Config: .github/quality-gate.yml. Workflow: |
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.
What
In coder mode, a response whose tool call came out as
<invoke name=...>/<parameter name=...>markup (the function-call format some models fall back to), or as a run of stray</invoke>, carried no call chatcli recognizes. The loop took the text for the final answer and printed "Task completed" with the action never run.Now the response is checked for that markup outside code fences and inline code. If it is there, the model is told that nothing was executed, shown the
<tool_call>format, and asked to resend, at most three times in a row (the counter resets when a turn acts).The markup is deliberately not converted into a call. Text that only looks like a call (quoted from a file or a tool result) must never run because it appeared in a response; the correction costs one turn and leaves every policy gate untouched.
Why
Found by reading the failures of a LongMemEval-V2 run: 33 of 484 coder attempts (7%) ended without the file the agent had been asked to write, and 29 of those 33 ended with exactly this markup as the final message. Among the 451 attempts that finished, 1 did.
Evidence
golangci-lintv2: 0 issues;go test ./cli/...passes.