@@ -2,6 +2,7 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
22import type { AgentHarness } from "../harness/types.js" ;
33import { makeAttemptResult , makeCompactionSuccess } from "./run.overflow-compaction.fixture.js" ;
44import {
5+ mockedBuildEmbeddedRunPayloads ,
56 mockedCompactDirect ,
67 mockedGetApiKeyForModel ,
78 mockedResolveAuthProfileOrder ,
@@ -37,14 +38,20 @@ describe("runEmbeddedAgent timeout recovery composition", () => {
3738 resetSharedRunIntegrationHarnessMocks ( ) ;
3839 } ) ;
3940
40- it ( "adopts a compacted transcript and retries with the complete runtime context" , async ( ) => {
41+ it ( "adopts a compacted transcript and retries with a continuation prompt" , async ( ) => {
42+ mockedBuildEmbeddedRunPayloads . mockReturnValue ( [ { text : "timeout recovery complete" } ] ) ;
4143 mockedRunEmbeddedAttempt
42- . mockResolvedValueOnce (
43- makeAttemptResult ( {
44+ . mockImplementationOnce ( async ( params ) => {
45+ params . onUserMessagePersisted ?.( {
46+ role : "user" ,
47+ content : "hello" ,
48+ timestamp : 1 ,
49+ } ) ;
50+ return makeAttemptResult ( {
4451 timedOut : true ,
4552 lastAssistant : { usage : { input : 160_000 } } as never ,
46- } ) ,
47- )
53+ } ) ;
54+ } )
4855 . mockResolvedValueOnce (
4956 makeAttemptResult ( {
5057 promptError : null ,
@@ -73,6 +80,12 @@ describe("runEmbeddedAgent timeout recovery composition", () => {
7380 sessionId : "timeout-rotated-session" ,
7481 sessionFile : "/tmp/timeout-rotated-session.json" ,
7582 } ) ;
83+ expect ( mockedRunEmbeddedAttempt . mock . calls [ 1 ] ?. [ 0 ] ?. prompt ) . toContain (
84+ "Continue from the current transcript" ,
85+ ) ;
86+ expect ( mockedRunEmbeddedAttempt . mock . calls [ 1 ] ?. [ 0 ] ?. prompt ) . not . toBe (
87+ overflowBaseRunParams . prompt ,
88+ ) ;
7689 const compactParams = mockedCompactDirect . mock . calls [ 0 ] ?. [ 0 ] as CompactParams | undefined ;
7790 expect ( compactParams ) . toMatchObject ( {
7891 sessionId : "test-session" ,
@@ -88,6 +101,7 @@ describe("runEmbeddedAgent timeout recovery composition", () => {
88101 } ,
89102 } ) ;
90103 expect ( result . meta . agentMeta ?. compactionTokensAfter ) . toBe ( 60_000 ) ;
104+ expect ( result . payloads ) . toEqual ( [ { text : "timeout recovery complete" } ] ) ;
91105 } ) ;
92106
93107 it ( "leaves timeout recovery to a forced unlocked Codex compaction owner" , async ( ) => {
0 commit comments