File tree Expand file tree Collapse file tree 6 files changed +62
-1
lines changed
Expand file tree Collapse file tree 6 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -186,8 +186,13 @@ export namespace Permission {
186186 public readonly permissionID : string ,
187187 public readonly toolCallID ?: string ,
188188 public readonly metadata ?: Record < string , any > ,
189+ public readonly reason ?: string ,
189190 ) {
190- super ( `The user rejected permission to use this specific tool call. You may try again with different parameters.` )
191+ super (
192+ reason !== undefined
193+ ? reason
194+ : `The user rejected permission to use this specific tool call. You may try again with different parameters.` ,
195+ )
191196 }
192197 }
193198}
Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ export namespace SessionProcessor {
136136
137137 const parts = await MessageV2 . parts ( input . assistantMessage . id )
138138 const lastThree = parts . slice ( - DOOM_LOOP_THRESHOLD )
139+
139140 if (
140141 lastThree . length === DOOM_LOOP_THRESHOLD &&
141142 lastThree . every (
@@ -160,6 +161,17 @@ export namespace SessionProcessor {
160161 input : value . input ,
161162 } ,
162163 } )
164+ } else if ( permission . doom_loop === "deny" ) {
165+ throw new Permission . RejectedError (
166+ input . assistantMessage . sessionID ,
167+ "doom_loop" ,
168+ value . toolCallId ,
169+ {
170+ tool : value . toolName ,
171+ input : value . input ,
172+ } ,
173+ `You seem to be stuck in a doom loop, please stop repeating the same action` ,
174+ )
163175 }
164176 }
165177 }
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ export const EditTool = Tool.define("edit", {
5757 parentDir,
5858 } ,
5959 } )
60+ } else if ( agent . permission . external_directory === "deny" ) {
61+ throw new Permission . RejectedError (
62+ ctx . sessionID ,
63+ "external_directory" ,
64+ ctx . callID ,
65+ {
66+ filepath : filePath ,
67+ parentDir,
68+ } ,
69+ `File ${ filePath } is not in the current working directory` ,
70+ )
6071 }
6172 }
6273
Original file line number Diff line number Diff line change @@ -68,6 +68,17 @@ export const PatchTool = Tool.define("patch", {
6868 parentDir,
6969 } ,
7070 } )
71+ } else if ( agent . permission . external_directory === "deny" ) {
72+ throw new Permission . RejectedError (
73+ ctx . sessionID ,
74+ "external_directory" ,
75+ ctx . callID ,
76+ {
77+ filepath : filePath ,
78+ parentDir,
79+ } ,
80+ `File ${ filePath } is not in the current working directory` ,
81+ )
7182 }
7283 }
7384
Original file line number Diff line number Diff line change @@ -46,6 +46,17 @@ export const ReadTool = Tool.define("read", {
4646 parentDir,
4747 } ,
4848 } )
49+ } else if ( agent . permission . external_directory === "deny" ) {
50+ throw new Permission . RejectedError (
51+ ctx . sessionID ,
52+ "external_directory" ,
53+ ctx . callID ,
54+ {
55+ filepath : filepath ,
56+ parentDir,
57+ } ,
58+ `File ${ filepath } is not in the current working directory` ,
59+ )
4960 }
5061 }
5162
Original file line number Diff line number Diff line change @@ -36,6 +36,17 @@ export const WriteTool = Tool.define("write", {
3636 parentDir,
3737 } ,
3838 } )
39+ } else if ( agent . permission . external_directory === "deny" ) {
40+ throw new Permission . RejectedError (
41+ ctx . sessionID ,
42+ "external_directory" ,
43+ ctx . callID ,
44+ {
45+ filepath : filepath ,
46+ parentDir,
47+ } ,
48+ `File ${ filepath } is not in the current working directory` ,
49+ )
3950 }
4051 }
4152
You can’t perform that action at this time.
0 commit comments