@@ -10,6 +10,7 @@ import {
1010 OrchestratorMcpDelegateTaskResult ,
1111 OrchestratorMcpThreadInterruptResult ,
1212 OrchestratorMcpThreadSendResult ,
13+ OrchestratorMcpThreadReadResult ,
1314 ProjectId ,
1415 ProviderDriverKind ,
1516 ProviderInstanceId ,
@@ -77,6 +78,7 @@ const delegatedResult = "Delegated API boundary inspected.";
7778const cancellationPrompt = "Remain active until the parent cancels this delegated task." ;
7879const queuedFollowupPrompt = "Complete the queued follow-up and return the final result." ;
7980const queuedFollowupResult = "Queued delegated follow-up completed." ;
81+ const decodeThreadRead = Schema . decodeUnknownEffect ( OrchestratorMcpThreadReadResult ) ;
8082
8183const decodeDelegateTaskResult = Schema . decodeUnknownEffect ( OrchestratorMcpDelegateTaskResult ) ;
8284const decodeThreadInterruptResult = Schema . decodeUnknownEffect (
@@ -196,6 +198,11 @@ describe("orchestrator MCP toolkit", () => {
196198 { label : "distinct" , result : queuedFollowupResult , latestSummary : queuedFollowupResult } ,
197199 { label : "identical" , result : delegatedResult , latestSummary : null } ,
198200 { label : "emoji" , result : "😀" , latestSummary : "😀" } ,
201+ {
202+ label : "paginated" ,
203+ result : "git safety " . repeat ( 120 ) ,
204+ latestSummary : "git safety " . repeat ( 120 ) ,
205+ } ,
199206 ] ) ( "reports $label child results" , ( { result, latestSummary } ) =>
200207 Effect . scoped (
201208 Effect . gen ( function * ( ) {
@@ -678,11 +685,40 @@ describe("orchestrator MCP toolkit", () => {
678685 const read = yield * invoke ( "t3_thread_read" , {
679686 threadId : delegated . childThreadId ,
680687 limit : 100 ,
681- maxCharsPerItem : result === "😀" ? 1 : 20_000 ,
688+ ... ( result === "😀" ? { maxCharsPerItem : 1 } : { } ) ,
682689 } ) . pipe ( Effect . withTracer ( tracer ) ) ;
683690 expect ( read . isError ) . not . toBe ( true ) ;
684691 expect ( transferReads . length ) . toBeGreaterThan ( 0 ) ;
685- expect ( read . structuredContent ) . toEqual ( parentlessRead . structuredContent ) ;
692+ const firstPage = yield * decodeThreadRead ( read . structuredContent ) ;
693+ const finalItem = firstPage . items . find ( ( item ) => item . text === result . slice ( 0 , 500 ) ) ;
694+ expect ( finalItem ) . toBeDefined ( ) ;
695+ if ( result . length > 500 ) {
696+ yield * invoke ( "t3_thread_read" , {
697+ threadId : delegated . childThreadId ,
698+ itemId : finalItem ! . itemId ,
699+ textOffset : result . length ,
700+ } ) ;
701+ } else {
702+ expect ( read . structuredContent ) . toEqual ( parentlessRead . structuredContent ) ;
703+ }
704+ let text = finalItem ! . text ?? "" ;
705+ let nextTextOffset = finalItem ?. nextTextOffset ?? null ;
706+ while ( nextTextOffset !== null ) {
707+ const beforeContinuation = yield * orchestrator . getThreadProjection ( parentThreadId ) ;
708+ expect (
709+ beforeContinuation . subagents . find ( ( task ) => task . id === queuedFollowup . taskId )
710+ ?. completionDelivery ?. state ,
711+ ) . toBe ( "claimed" ) ;
712+ const continuation = yield * invoke ( "t3_thread_read" , {
713+ threadId : delegated . childThreadId ,
714+ itemId : finalItem ! . itemId ,
715+ textOffset : nextTextOffset ,
716+ } ) ;
717+ const nextPage = yield * decodeThreadRead ( continuation . structuredContent ) ;
718+ text += nextPage . items [ 0 ] ?. text ?? "" ;
719+ nextTextOffset = nextPage . items [ 0 ] ?. nextTextOffset ?? null ;
720+ }
721+ expect ( text ) . toBe ( result ) ;
686722 const afterRead = yield * orchestrator . getThreadProjection ( parentThreadId ) ;
687723 expect (
688724 afterRead . subagents . find ( ( task ) => task . id === queuedFollowup . taskId )
0 commit comments