File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,18 @@ const pruneToolInputs = (
206206 continue
207207 }
208208
209- if ( part . state . input ?. content !== undefined ) {
209+ // Write tool has content field, edit tool has oldString/newString fields
210+ if ( part . tool === 'write' && part . state . input ?. content !== undefined ) {
210211 part . state . input . content = PRUNED_TOOL_INPUT_REPLACEMENT
211212 }
213+ if ( part . tool === 'edit' ) {
214+ if ( part . state . input ?. oldString !== undefined ) {
215+ part . state . input . oldString = PRUNED_TOOL_INPUT_REPLACEMENT
216+ }
217+ if ( part . state . input ?. newString !== undefined ) {
218+ part . state . input . newString = PRUNED_TOOL_INPUT_REPLACEMENT
219+ }
220+ }
212221 }
213222 }
214223}
Original file line number Diff line number Diff line change @@ -55,14 +55,25 @@ export const calculateTokensSaved = (
5555 }
5656 // For write and edit tools, count input content as that is all we prune for these tools
5757 // (input is present in both completed and error states)
58- if ( part . tool === "write" || part . tool === "edit" ) {
58+ if ( part . tool === "write" ) {
5959 const inputContent = part . state . input ?. content
6060 const content = typeof inputContent === 'string'
6161 ? inputContent
6262 : JSON . stringify ( inputContent ?? '' )
6363 contents . push ( content )
6464 continue
6565 }
66+ if ( part . tool === "edit" ) {
67+ const oldString = part . state . input ?. oldString
68+ const newString = part . state . input ?. newString
69+ if ( typeof oldString === 'string' ) {
70+ contents . push ( oldString )
71+ }
72+ if ( typeof newString === 'string' ) {
73+ contents . push ( newString )
74+ }
75+ continue
76+ }
6677 // For other tools, count output or error based on status
6778 if ( part . state . status === "completed" ) {
6879 const content = typeof part . state . output === 'string'
You can’t perform that action at this time.
0 commit comments