77
88function createRuntime ( ) {
99 return {
10- createRunningTaskRun : vi . fn ( ) ,
10+ tryCreateRunningTaskRun : vi . fn ( ( params ) => ( { taskId : "task-native-subagent" , ... params } ) ) ,
1111 recordTaskRunProgressByRunId : vi . fn ( ( ) => [ ] ) ,
1212 finalizeTaskRunByRunId : vi . fn ( ( ) => [ ] ) ,
1313 } as unknown as TaskLifecycleRuntime ;
@@ -49,7 +49,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
4949 } ,
5050 } ) ;
5151
52- expect ( runtime . createRunningTaskRun ) . toHaveBeenCalledWith ( {
52+ expect ( runtime . tryCreateRunningTaskRun ) . toHaveBeenCalledWith ( {
5353 sourceId : "codex-thread:child-thread" ,
5454 agentId : "main" ,
5555 runId : "codex-thread:child-thread" ,
@@ -62,7 +62,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
6262 lastEventAt : 20_000 ,
6363 progressSummary : "Codex native subagent started." ,
6464 } ) ;
65- expect ( vi . mocked ( runtime . createRunningTaskRun ) . mock . calls [ 0 ] ?. [ 0 ] ) . not . toHaveProperty (
65+ expect ( vi . mocked ( runtime . tryCreateRunningTaskRun ) . mock . calls [ 0 ] ?. [ 0 ] ) . not . toHaveProperty (
6666 "childSessionKey" ,
6767 ) ;
6868 expect ( runtime . recordTaskRunProgressByRunId ) . toHaveBeenCalledWith ( {
@@ -99,7 +99,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
9999 } ,
100100 } ) ;
101101
102- expect ( runtime . createRunningTaskRun ) . not . toHaveBeenCalled ( ) ;
102+ expect ( runtime . tryCreateRunningTaskRun ) . not . toHaveBeenCalled ( ) ;
103103 expect ( runtime . recordTaskRunProgressByRunId ) . not . toHaveBeenCalled ( ) ;
104104 expect ( runtime . finalizeTaskRunByRunId ) . not . toHaveBeenCalled ( ) ;
105105 } ) ;
@@ -133,7 +133,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
133133 mirror . handleNotification ( notification ) ;
134134 mirror . handleNotification ( notification ) ;
135135
136- expect ( runtime . createRunningTaskRun ) . toHaveBeenCalledTimes ( 1 ) ;
136+ expect ( runtime . tryCreateRunningTaskRun ) . toHaveBeenCalledTimes ( 1 ) ;
137137 } ) ;
138138
139139 it ( "maps Codex thread status changes onto the mirrored task run" , ( ) => {
@@ -228,7 +228,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
228228 } ,
229229 } ) ;
230230
231- expect ( runtime . createRunningTaskRun ) . toHaveBeenCalledWith ( {
231+ expect ( runtime . tryCreateRunningTaskRun ) . toHaveBeenCalledWith ( {
232232 sourceId : "codex-thread:child-thread" ,
233233 runId : "codex-thread:child-thread" ,
234234 label : "Codex subagent" ,
@@ -240,7 +240,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
240240 lastEventAt : 40_000 ,
241241 progressSummary : "Codex native subagent spawned." ,
242242 } ) ;
243- expect ( vi . mocked ( runtime . createRunningTaskRun ) . mock . calls [ 0 ] ?. [ 0 ] ) . not . toHaveProperty (
243+ expect ( vi . mocked ( runtime . tryCreateRunningTaskRun ) . mock . calls [ 0 ] ?. [ 0 ] ) . not . toHaveProperty (
244244 "childSessionKey" ,
245245 ) ;
246246 expect ( runtime . recordTaskRunProgressByRunId ) . toHaveBeenCalledWith ( {
@@ -282,7 +282,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
282282 } ,
283283 } ) ;
284284
285- expect ( runtime . createRunningTaskRun ) . toHaveBeenCalledWith (
285+ expect ( runtime . tryCreateRunningTaskRun ) . toHaveBeenCalledWith (
286286 expect . objectContaining ( {
287287 runId : "codex-thread:child-thread" ,
288288 task : "inspect one thing" ,
@@ -319,7 +319,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
319319 } ,
320320 } ) ;
321321
322- expect ( runtime . createRunningTaskRun ) . toHaveBeenCalledWith (
322+ expect ( runtime . tryCreateRunningTaskRun ) . toHaveBeenCalledWith (
323323 expect . objectContaining ( {
324324 runId : "codex-thread:child-thread" ,
325325 task : "inspect one thing" ,
0 commit comments