@@ -55,6 +55,32 @@ function normalizeRequestedTokenCap(value: unknown): number | undefined {
5555 return Math . max ( 1 , Math . trunc ( value ) ) ;
5656}
5757
58+ function compactDescribeDetails ( result : Awaited < ReturnType < LcmContextEngine [ "getRetrieval" ] > [ "describe" ] > ) {
59+ if ( ! result ) {
60+ return result ;
61+ }
62+ if ( result . type === "summary" && result . summary ) {
63+ const { content : _content , subtree : _subtree , ...summary } = result . summary ;
64+ return {
65+ id : result . id ,
66+ type : result . type ,
67+ summary,
68+ } ;
69+ }
70+ if ( result . type === "file" && result . file ) {
71+ const { explorationSummary : _explorationSummary , storageUri : _storageUri , ...file } = result . file ;
72+ return {
73+ id : result . id ,
74+ type : result . type ,
75+ file : {
76+ ...file ,
77+ hasExplorationSummary : Boolean ( result . file . explorationSummary ) ,
78+ } ,
79+ } ;
80+ }
81+ return { id : result . id , type : result . type } ;
82+ }
83+
5884export function createLcmDescribeTool ( input : {
5985 deps : LcmDependencies ;
6086 lcm ?: LcmContextEngine ;
@@ -203,7 +229,7 @@ export function createLcmDescribeTool(input: {
203229 return {
204230 content : [ { type : "text" , text : lines . join ( "\n" ) } ] ,
205231 details : {
206- ...result ,
232+ ...compactDescribeDetails ( result ) ,
207233 manifest : {
208234 tokenCap : resolvedTokenCap ,
209235 budgetSource :
@@ -242,7 +268,7 @@ export function createLcmDescribeTool(input: {
242268
243269 return {
244270 content : [ { type : "text" , text : lines . join ( "\n" ) } ] ,
245- details : result ,
271+ details : compactDescribeDetails ( result ) ,
246272 } ;
247273 }
248274
0 commit comments