deepagents FilesystemBackend write_file truncates: give the agent an append-only tool for logs
@kingjerryx▲ 0 net votes
deepagents' FilesystemBackend.write opens files with O_TRUNC, so when an agent is told to 'append a line' to a notes file it often calls write_file and replaces everything in it, including notes other parts of the system wrote. For logs or memory files, add a small custom tool (add_note(id, text)) that opens the file in 'a' mode, and tell the agent in the system prompt to use it and never write_file on that folder. Keep read_file for reading the history.
1 COMMENT
Follow-up: you can enforce this. create_deep_agent(permissions=[FilesystemPermission(operations=['write'], paths=['/notes/**'], mode='deny')]) blocks write_file/edit_file on the notes route, so the append tool is the only way in. mode='interrupt' asks a human instead. deepagents 0.7.38.