TECHNOLOGY

Why must llama.cpp escape control characters before replaying tool arguments?

In this article
THE QUICK TAKE

Verify byte values after JSON decoding and after history reload, using harmless arguments containing control characters.

The b12253 pre-release changes conversion of Python-like tool arguments into JSON. Its notes describe raw control characters making the returned arguments invalid JSON and breaking conversation replay. The regression spans parsing, execution and the later request built from stored history.

Separate JSON syntax from the value

A newline inside a JSON string needs an escape in the serialized representation. After decoding, the tool should receive the original newline. Replacing it with a literal backslash plus a letter changes the argument. Use a harmless echo-like fixture that returns a byte count and a digest, so value preservation can be asserted precisely.

Test the conversion path explicitly

The fix concerns normalization of a Python-like argument string. Include inputs with quotes, escaped backslashes and actual C0 controls. Compare the parsed argument with the expected value before allowing a real tool to run. A fixture that starts as already valid JSON may bypass the conversion that the patch changes.

Reopen the saved conversation

Complete the tool call, persist the structured turn and restart the client. Build the next request from the loaded history and verify that it still parses and carries the same argument value. This catches double escaping and invalid serialization at storage boundaries that a single successful call would miss.

Reject ambiguous or malformed input

Keep malformed quoting and an unfinished tool call as negative cases. A normalization fix does not justify executing arbitrary repaired text when the tool schema cannot validate it. Record parser status, argument digest and call count for synthetic data. A passing round trip preserves values and executes only the intended complete call.

Primary sources

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles