AI Code Edits Cut by 60%
Key point
Dirac significantly lowered code editing costs with single-token anchors and Myers diff.
Details
Dirac has extended hash-anchor-based code editing, unveiling a new editing method that combines single-token anchors with a stateful backend instead of line-number hashes.
The core idea is to attach anchors to each line of a file during the read phase, and during edits, have the model present only the start/end anchors and replacement code, reducing output tokens. The company explained that this can reduce edit responses to O(R), instead of O(S+R) for the existing search/replace approach.
The implementation consists of the following components.
- Anchor: About 1,700 single-token anchors selected using
tiktoken - Delimiter:
§separating code and anchors - Validator: Matches the full line string that the anchor points to
- State Manager: State management that maintains anchor mappings per file
- Reconciler: Reassigns new anchors only to changed lines using Myers diff
Comparison results were also presented. Across 8 test tasks, Dirac achieved 8/8 correct answers with an average cost of $0.18, while the comparison group's average cost was in the $0.38–$0.73 range. The company claimed lower costs were also shown per example task in transformers, vscode, and django work.
The company stated that this method is currently applied to Dirac's VS Code extension and CLI.