@@ -36,6 +36,7 @@ export const TaskTool = Tool.define(
3636 Effect . gen ( function * ( ) {
3737 const agent = yield * Agent . Service
3838 const config = yield * Config . Service
39+ const sessions = yield * Session . Service
3940
4041 const run = Effect . fn ( "TaskTool.execute" ) ( function * ( params : z . infer < typeof parameters > , ctx : Tool . Context ) {
4142 const cfg = yield * config . get ( )
@@ -62,44 +63,41 @@ export const TaskTool = Tool.define(
6263
6364 const taskID = params . task_id
6465 const session = taskID
65- ? yield * Effect . promise ( ( ) => {
66- const id = SessionID . make ( taskID )
67- return Session . get ( id ) . catch ( ( ) => undefined )
68- } )
66+ ? yield * sessions . get ( SessionID . make ( taskID ) ) . pipe (
67+ Effect . catchCause ( ( ) => Effect . succeed ( undefined ) ) ,
68+ )
6969 : undefined
7070 const nextSession =
7171 session ??
72- ( yield * Effect . promise ( ( ) =>
73- Session . create ( {
74- parentID : ctx . sessionID ,
75- title : params . description + ` (@${ next . name } subagent)` ,
76- permission : [
77- ...( canTodo
78- ? [ ]
79- : [
80- {
81- permission : "todowrite" as const ,
82- pattern : "*" as const ,
83- action : "deny" as const ,
84- } ,
85- ] ) ,
86- ...( canTask
87- ? [ ]
88- : [
89- {
90- permission : id ,
91- pattern : "*" as const ,
92- action : "deny" as const ,
93- } ,
94- ] ) ,
95- ...( cfg . experimental ?. primary_tools ?. map ( ( item ) => ( {
96- pattern : "*" ,
97- action : "allow" as const ,
98- permission : item ,
99- } ) ) ?? [ ] ) ,
100- ] ,
101- } ) ,
102- ) )
72+ ( yield * sessions . create ( {
73+ parentID : ctx . sessionID ,
74+ title : params . description + ` (@${ next . name } subagent)` ,
75+ permission : [
76+ ...( canTodo
77+ ? [ ]
78+ : [
79+ {
80+ permission : "todowrite" as const ,
81+ pattern : "*" as const ,
82+ action : "deny" as const ,
83+ } ,
84+ ] ) ,
85+ ...( canTask
86+ ? [ ]
87+ : [
88+ {
89+ permission : id ,
90+ pattern : "*" as const ,
91+ action : "deny" as const ,
92+ } ,
93+ ] ) ,
94+ ...( cfg . experimental ?. primary_tools ?. map ( ( item ) => ( {
95+ pattern : "*" ,
96+ action : "allow" as const ,
97+ permission : item ,
98+ } ) ) ?? [ ] ) ,
99+ ] ,
100+ } ) )
103101
104102 const msg = yield * Effect . sync ( ( ) => MessageV2 . get ( { sessionID : ctx . sessionID , messageID : ctx . messageID } ) )
105103 if ( msg . info . role !== "assistant" ) return yield * Effect . fail ( new Error ( "Not an assistant message" ) )
0 commit comments