Skip to main content

Module write_files

Module write_files 

Source
Expand description

write_files tool — create or overwrite MANY files in a single call.

Why: write_file is one-file-per-call, and on every bake-off run the file count equalled the write-turn count 1:1 — an 8-file scaffold cost 8 turns, the single biggest driver of tcode’s high agent-turn count. PR #2666 lets the loop execute several tool calls per turn, but the model does not always batch; a dedicated write_files tool decouples turn-count from file-count STRUCTURALLY — one call writes N files regardless of whether the model batches. (#2681.) What: WriteFilesTool takes a files array of {path, content} objects, writes each (creating parent dirs) scoped to working_dir, and reports a per-file result. A failure on one file does not abort the others — every file’s outcome is reported so the model can retry only what failed. Every successfully written path is batched into ONE best-effort mid-task incremental trusty-search index update (issue: mid-task incremental re-indexing) so search_code sees the whole batch within the same task. Test: See #[cfg(test)] below — covers a multi-file write, partial failure, empty array, and path traversal.

Structs§

WriteFilesTool
ToolExecutor that creates or overwrites a batch of files in one call.

Constants§

WRITE_FILES_TOOL_NAME
Canonical name of the batch-write tool.