@@ -24,13 +24,6 @@ if (!process.env.OPENROUTER_API_KEY) {
2424 throw new Error ( 'OPENROUTER_API_KEY is not set (E2E_OPENROUTER_API_KEY in the e2e-tests .env)' ) ;
2525}
2626
27- // pi-durable 1.2.0 renamed the tool result field `content` to `output`. The app runs on 1.0.0 and on the
28- // latest version, so its tool results set both.
29- const textResult = text => {
30- const blocks = [ { type : 'text' , text } ] ;
31- return { output : blocks , content : blocks } ;
32- } ;
33-
3427const dataDir = fileURLToPath ( new URL ( '../.data/' , import . meta. url ) ) ;
3528mkdirSync ( dataDir , { recursive : true } ) ;
3629
@@ -44,9 +37,9 @@ const tools = [
4437 parameters : Type . Object ( { city : Type . String ( ) } ) ,
4538 // The manual span should nest under the SDK's `execute_tool` span.
4639 execute : async args =>
47- Sentry . startSpan ( { name : 'resolve-weather' , attributes : { 'weather.city' : args . city } } , ( ) =>
48- textResult ( `It is 21 degrees and sunny in ${ args . city } .` ) ,
49- ) ,
40+ Sentry . startSpan ( { name : 'resolve-weather' , attributes : { 'weather.city' : args . city } } , ( ) => ( {
41+ output : [ { type : 'text' , text : `It is 21 degrees and sunny in ${ args . city } .` } ] ,
42+ } ) ) ,
5043 } ) ,
5144 defineTool ( {
5245 name : 'fail_now' ,
@@ -67,7 +60,7 @@ const tools = [
6760 try {
6861 writeFileSync ( `${ dataDir } crashed-${ args . job } ` , 'crashed once' , { flag : 'wx' } ) ;
6962 } catch {
70- return textResult ( `Step of job ${ args . job } completed.` ) ;
63+ return { output : [ { type : 'text' , text : `Step of job ${ args . job } completed.` } ] } ;
7164 }
7265 process . exit ( CRASH_EXIT_CODE ) ;
7366 } ,
@@ -87,14 +80,14 @@ const tools = [
8780 const request = { type : 'input' , content : args . task , requestId : `delegate:${ api . taskId } ` } ;
8881 const settled = await ( await child . submit ( request , toolContext ) ) . wait ( toolContext ) ;
8982 if ( settled . status !== 'done' ) {
90- return { isError : true , ... textResult ( `Subagent ended: ${ settled . reason } ` ) } ;
83+ return { isError : true , output : [ { type : 'text' , text : `Subagent ended: ${ settled . reason } ` } ] } ;
9184 }
9285 const answer = await api . commit ( tx => tx . entry ( AssistantEntry , settled . answer ) , toolContext ) ;
9386 const text = ( answer ?. model ?. [ 0 ] ?. content ?? [ ] )
9487 . filter ( part => part . type === 'text' )
9588 . map ( part => part . text )
9689 . join ( '' ) ;
97- return textResult ( text ) ;
90+ return { output : [ { type : ' text' , text } ] } ;
9891 } ,
9992 } ) ,
10093] ;
0 commit comments