Commit 63249cb
committed
fix(agent): a markdown "Done:" line ends the run — the finished answer was being nudged
The agent finished, and then finished again. Its answer opened with
**Done:** created a styled, renderable workflow diagram of how a chat
message becomes a reply.
and the loop replied "Stop planning. You have read enough. Make your next
edit_file (or write_file) call NOW …". The model answered with a second
"Done:", and that is what the user saw.
A turn with no tool call ends the run when one of its lines starts with
"Done:" — the ending SYSTEM_BASE asks for. The test read the text literally,
/(^|\n)\s*done\s*:/, and the `**` sits between the line start and the word,
so the line did not count. The turn fell through to the stall check, where
/\bnext[, ]/ takes any "next " for a promise of more work; this answer quoted
a label from the diagram, "Your next message updates context". Run on
develop's loop, that text makes it ask the model for a second turn.
The test is now a function, saysDone(), and it looks for the line with the
markdown marks stripped: quote, heading and list marks at line starts, then
emphasis marks. So **Done:**, __Done:__, `Done:`, "## Done:", "> Done:",
"- Done:" and "1. Done:" all count. "Not done: two tests fail" does not, and
neither does a turn that announces an edit and makes none.
The second half of the test — text whose last word is "done" — still reads the
text as written. With the marks stripped, a turn that ends in a fenced shell
loop ends in the word too:
Let me run this to rename them:
```bash
for f in *.txt; do
mv "$f" "${f%.txt}.md"
done
```
That is a stall, a command pasted where a tool call belonged, and it stays
nudged. The price: "**All done.**" is not recognised, as it is not on develop.
Nothing else moves — the auto-verify call, the stall check, the nudge's
wording and its counter are as they were.
One side effect of counting list items. A turn that holds a "- Done: parser"
bullet in a progress list and also promises more work was nudged on develop,
and now ends the run. Without the bullet mark the same text ended it already.
Not fixed here:
- A Done line behind an emoji ("✅ **Done:** …") is still not recognised, so
with a "next " in the answer it is still nudged.
- A finished answer with no Done line that says "Next, run it against staging"
is still taken for a promise. That is the stall check's question, and it is
left alone.
test/agentDone.test.js, 7 cases. The verdicts, called directly; and the real
loop on scripted turns, with vscode and the provider replaced the way
agentRunCommand.test.js replaces them, because a verdict the loop does not
consult fixes nothing. The reported answer ends the run in one turn; the
announced edit is nudged; the pasted loop is nudged. The suite awaits runAgent
and nothing else — no timers, no waiting on the event loop. It fails with
develop's test inside the function (2 cases), with the function fixed and the
loop not calling it (1), and with the last-word test moved onto the stripped
text (2).
50 suites, 969 cases, 0 failing (scripts/test-extensions.sh) on this commit's
tree, on macOS with Node 24 and in a Linux container with Node 20. With the
checkout's tsc, agent.js reports the same 94 diagnostics as on develop.
Not run in the editor against a live model: the loop was driven by scripted
turns.1 parent f8b6193 commit 63249cb
2 files changed
Lines changed: 208 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
718 | 740 | | |
719 | 741 | | |
720 | 742 | | |
| |||
1021 | 1043 | | |
1022 | 1044 | | |
1023 | 1045 | | |
1024 | | - | |
| 1046 | + | |
1025 | 1047 | | |
1026 | 1048 | | |
1027 | 1049 | | |
| |||
1070 | 1092 | | |
1071 | 1093 | | |
1072 | 1094 | | |
1073 | | - | |
| 1095 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
0 commit comments