Symptom
SandboxApplyPatchTool parses a freeform patch with raw_input.splitlines(). A form feed or U+2028 inside a line is treated as a line break, so *** Add File: fails with Invalid Add File line: page two and *** Update File: fails with apply_diff -> Invalid Line: b";.
Evidence what you'll see
- The tool's Lark grammar only ends a line at
LF.agents/apply_diff.pyalso splits on"\n".str.splitlines()also breaks at\v,\f,\x1c-\x1e,\x85,\u2028,\u2029, and a bare\r. - A form feed between sections of a Python or C file, or a
\u2028inside a JS string, is enough. An Update File failure happens even when the character is only in a context line. - Splitting the envelope on
"\n"makes both cases work in the report's reproduction.
Why it happens
Envelope parsing used every Python line separator, so a patch the grammar accepts was rejected. Pull request 5365 parses LF-delimited envelope lines, keeps CRLF normalization, and keeps embedded form feeds and Unicode separators as file content.
Affected versions
Agents Python SDK main at 125efa0 (0.23.1). Python 3.12.3, Linux. The parser is called directly; the linked issue does not name a model.
Fix steps
0 of 2 done
Your check marks stay in this browser only.
How to check it worked
- An Add File patch whose contents include a form feed creates the file, and an Update File patch with
U+2028in a context line applies withoutInvalid Add File lineorInvalid Line.
If it still fails
- The linked issue does not describe
Invalid Add File linefrom an embedded form feed onv0.24.0.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it