File tree Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 11import { z } from 'zod' ;
2- import { Agent , run , tool } from '@openai/agents' ;
2+ import { Agent , Runner , tool } from '@openai/agents' ;
33
44const getWeatherTool = tool ( {
55 name : 'get_weather' ,
@@ -24,7 +24,14 @@ const agent = new Agent({
2424} ) ;
2525
2626async function main ( ) {
27- const result = await run ( agent , 'What is the weather in San Francisco?' ) ;
27+ const runner = new Runner ( {
28+ groupId : 'My group' ,
29+ traceMetadata : { user_id : '123' } ,
30+ } ) ;
31+ const result = await runner . run (
32+ agent ,
33+ 'What is the weather in San Francisco?' ,
34+ ) ;
2835
2936 console . log ( result . finalOutput ) ;
3037}
Original file line number Diff line number Diff line change @@ -956,13 +956,21 @@ export class Runner extends RunHooks<any, AgentOutputType<unknown>> {
956956 } ) ;
957957 }
958958
959- return getOrCreateTrace ( async ( ) => {
960- if ( options ?. stream ) {
961- return this . #runIndividualStream( agent , input , options ) ;
962- } else {
963- return this . #runIndividualNonStream( agent , input , options ) ;
964- }
965- } ) ;
959+ return getOrCreateTrace (
960+ async ( ) => {
961+ if ( options ?. stream ) {
962+ return this . #runIndividualStream( agent , input , options ) ;
963+ } else {
964+ return this . #runIndividualNonStream( agent , input , options ) ;
965+ }
966+ } ,
967+ {
968+ traceId : this . config . traceId ,
969+ name : this . config . workflowName ,
970+ groupId : this . config . groupId ,
971+ metadata : this . config . traceMetadata ,
972+ } ,
973+ ) ;
966974 }
967975}
968976
You can’t perform that action at this time.
0 commit comments