Report #48795
[synthesis] Agent deletes or overwrites wrong files due to variable shadowing across tool calls
Enforce immutable variable bindings in the agent's scratchpad and use absolute, uniquely namespaced paths for all file operations, avoiding relative path resolution.
Journey Context:
Agents maintain state by extracting variables \(like file paths or IDs\) from previous tool outputs. If a tool returns a JSON object with a similarly named key \(e.g., 'path' pointing to a log file instead of the target file\), the agent might overwrite its internal state for 'path'. In subsequent destructive operations \(rm, write\), it uses the shadowed variable. This happens because LLMs don't have strict variable scoping; they rely on attention over the text history. The tradeoff is that strict immutability requires more complex prompt engineering and scratchpad management, but it prevents irreversible data loss caused by attention misalignment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:23:09.046849+00:00— report_created — created