fix(chat): prevent double-escape corruption of messages/tools in agentic bridge #20
Reference in New Issue
Block a user
Delete Branch "fix/bridge-save-serialization"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
bridge_savewas callingjson_safe()onmessagesandtools_jsonbefore storing them as JSON string fields. Both values are already well-formed JSON arrays containing double quotes, sojson_safeadded a second escape layer.agentic_resumecalledjson_get()which strips only one layer, leaving the messages array corrupted before passing it back toagentic_loop.messagesasmessages_rawandtools_jsonastools_rawas inline raw JSON values (not string-escaped), and read them back withjson_get_raw. Scalar strings (model,safe_sys,tools_log,tool_use_id) remain as string fields viajson_safe/json_getsince they do not contain nested JSON structure.agentic_resumefalls back to the old string-escaped fields if the raw fields are absent, so any session suspended before this fix can still be resumed.write_filereturning a pre-escaped literal instead of callingjson_safeconsistently with every other tool result.Test plan
write_filetool result parses correctly in the tool loopView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.