@@ -21,7 +21,12 @@ async def on_pre_tool_use(input_data, invocation):
2121 # Allow the tool to run
2222 return {"permissionDecision" : "allow" }
2323
24- session = await ctx .client .create_session ({"hooks" : {"on_pre_tool_use" : on_pre_tool_use }})
24+ session = await ctx .client .create_session (
25+ {
26+ "hooks" : {"on_pre_tool_use" : on_pre_tool_use },
27+ "on_permission_request" : lambda _req , _inv : {"kind" : "approved" },
28+ }
29+ )
2530
2631 # Create a file for the model to read
2732 write_file (ctx .work_dir , "hello.txt" , "Hello from the test!" )
@@ -49,7 +54,12 @@ async def on_post_tool_use(input_data, invocation):
4954 assert invocation ["session_id" ] == session .session_id
5055 return None
5156
52- session = await ctx .client .create_session ({"hooks" : {"on_post_tool_use" : on_post_tool_use }})
57+ session = await ctx .client .create_session (
58+ {
59+ "hooks" : {"on_post_tool_use" : on_post_tool_use },
60+ "on_permission_request" : lambda _req , _inv : {"kind" : "approved" },
61+ }
62+ )
5363
5464 # Create a file for the model to read
5565 write_file (ctx .work_dir , "world.txt" , "World from the test!" )
@@ -87,7 +97,8 @@ async def on_post_tool_use(input_data, invocation):
8797 "hooks" : {
8898 "on_pre_tool_use" : on_pre_tool_use ,
8999 "on_post_tool_use" : on_post_tool_use ,
90- }
100+ },
101+ "on_permission_request" : lambda _req , _inv : {"kind" : "approved" },
91102 }
92103 )
93104
@@ -118,7 +129,12 @@ async def on_pre_tool_use(input_data, invocation):
118129 # Deny all tool calls
119130 return {"permissionDecision" : "deny" }
120131
121- session = await ctx .client .create_session ({"hooks" : {"on_pre_tool_use" : on_pre_tool_use }})
132+ session = await ctx .client .create_session (
133+ {
134+ "hooks" : {"on_pre_tool_use" : on_pre_tool_use },
135+ "on_permission_request" : lambda _req , _inv : {"kind" : "approved" },
136+ }
137+ )
122138
123139 # Create a file
124140 original_content = "Original content that should not be modified"
0 commit comments