Commit bf74d34
committed
fix(json-parse): exclude code-context tails from Windows-path heuristic
The repairJson helper detects unescaped backslashes in Windows path
strings (\bin, \users) and preserves them as literal characters
instead of rewriting them as JSON escape sequences. The detector keys
off a tail ending in `<non-alphanum><letter>:`, which matches genuine
drive letters like `C:` but also matches Python block openers like
`if x:`, `for x:`, `try:`, `def foo(x):`. When the next character
was a real newline, the model output got rewritten so the shell saw a
literal `\n` instead of an actual newline.
This broke any agent tool call that carried multi-line Python in a
heredoc, with the symptom that the shell parser threw
`SyntaxError: unexpected character after line continuation character`
and the cron agent burned thousands of output tokens trying to work
around the corruption.
Fix: reject any tail that contains code-context markers like parens,
braces, equals, semicolons, single-quotes, commas, shell redirects, or
pipes. Real Windows path tails do not contain those characters, but
nearly every Python/JS/shell block opener does.
Adds regression tests for the failing patterns and a mixed-content test
that confirms a Windows path adjacent to code still survives.
Refs #931391 parent 10d850b commit bf74d34
2 files changed
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
117 | 126 | | |
118 | 127 | | |
119 | 128 | | |
| |||
0 commit comments