@@ -11,6 +11,7 @@ import {
1111 OrchestratorMcpDelegateTaskResult ,
1212 OrchestratorMcpThreadInterruptResult ,
1313 OrchestratorMcpThreadSendResult ,
14+ OrchestratorMcpThreadReadResult ,
1415 ProjectId ,
1516 ProviderDriverKind ,
1617 ProviderInstanceId ,
@@ -79,6 +80,7 @@ const delegatedResult = "Delegated API boundary inspected.";
7980const cancellationPrompt = "Remain active until the parent cancels this delegated task." ;
8081const queuedFollowupPrompt = "Complete the queued follow-up and return the final result." ;
8182const queuedFollowupResult = "Queued delegated follow-up completed." ;
83+ const decodeThreadRead = Schema . decodeUnknownEffect ( OrchestratorMcpThreadReadResult ) ;
8284
8385const decodeDelegateTaskResult = Schema . decodeUnknownEffect ( OrchestratorMcpDelegateTaskResult ) ;
8486const decodeThreadInterruptResult = Schema . decodeUnknownEffect (
@@ -199,6 +201,11 @@ describe("orchestrator MCP toolkit", () => {
199201 { label : "distinct" , result : queuedFollowupResult , latestSummary : queuedFollowupResult } ,
200202 { label : "identical" , result : delegatedResult , latestSummary : null } ,
201203 { label : "emoji" , result : "😀" , latestSummary : "😀" } ,
204+ {
205+ label : "paginated" ,
206+ result : "git safety " . repeat ( 120 ) ,
207+ latestSummary : "git safety " . repeat ( 120 ) ,
208+ } ,
202209 ] ) ( "reports $label child results" , ( { result, latestSummary } ) =>
203210 Effect . scoped (
204211 Effect . gen ( function * ( ) {
@@ -682,11 +689,40 @@ describe("orchestrator MCP toolkit", () => {
682689 const read = yield * invoke ( "t3_thread_read" , {
683690 threadId : delegated . childThreadId ,
684691 limit : 100 ,
685- maxCharsPerItem : result === "😀" ? 1 : 20_000 ,
692+ ... ( result === "😀" ? { maxCharsPerItem : 1 } : { } ) ,
686693 } ) . pipe ( Effect . withTracer ( tracer ) ) ;
687694 expect ( read . isError ) . not . toBe ( true ) ;
688695 expect ( transferReads . length ) . toBeGreaterThan ( 0 ) ;
689- expect ( read . structuredContent ) . toEqual ( parentlessRead . structuredContent ) ;
696+ const firstPage = yield * decodeThreadRead ( read . structuredContent ) ;
697+ const finalItem = firstPage . items . find ( ( item ) => item . text === result . slice ( 0 , 500 ) ) ;
698+ expect ( finalItem ) . toBeDefined ( ) ;
699+ if ( result . length > 500 ) {
700+ yield * invoke ( "t3_thread_read" , {
701+ threadId : delegated . childThreadId ,
702+ itemId : finalItem ! . itemId ,
703+ textOffset : result . length ,
704+ } ) ;
705+ } else {
706+ expect ( read . structuredContent ) . toEqual ( parentlessRead . structuredContent ) ;
707+ }
708+ let text = finalItem ! . text ?? "" ;
709+ let nextTextOffset = finalItem ?. nextTextOffset ?? null ;
710+ while ( nextTextOffset !== null ) {
711+ const beforeContinuation = yield * orchestrator . getThreadProjection ( parentThreadId ) ;
712+ expect (
713+ beforeContinuation . subagents . find ( ( task ) => task . id === queuedFollowup . taskId )
714+ ?. completionDelivery ?. state ,
715+ ) . toBe ( "claimed" ) ;
716+ const continuation = yield * invoke ( "t3_thread_read" , {
717+ threadId : delegated . childThreadId ,
718+ itemId : finalItem ! . itemId ,
719+ textOffset : nextTextOffset ,
720+ } ) ;
721+ const nextPage = yield * decodeThreadRead ( continuation . structuredContent ) ;
722+ text += nextPage . items [ 0 ] ?. text ?? "" ;
723+ nextTextOffset = nextPage . items [ 0 ] ?. nextTextOffset ?? null ;
724+ }
725+ expect ( text ) . toBe ( result ) ;
690726 const afterRead = yield * orchestrator . getThreadProjection ( parentThreadId ) ;
691727 expect (
692728 afterRead . subagents . find ( ( task ) => task . id === queuedFollowup . taskId )
0 commit comments