@@ -579,6 +579,24 @@ export class AcpSdkBackend implements AgentBackend {
579579 * expose model metadata (e.g. current Gemini ACP build) simply leave the
580580 * cache untouched.
581581 */
582+ private extractModelConfigOption ( response : Record < string , unknown > ) : {
583+ currentValue : string | null ;
584+ options : unknown [ ] ;
585+ } | null {
586+ if ( ! Array . isArray ( response . configOptions ) ) return null ;
587+
588+ for ( const entry of response . configOptions ) {
589+ if ( ! isObject ( entry ) ) continue ;
590+ if ( asString ( entry . category ) !== 'model' ) continue ;
591+ return {
592+ currentValue : asString ( entry . currentValue ) ,
593+ options : Array . isArray ( entry . options ) ? entry . options : [ ]
594+ } ;
595+ }
596+
597+ return null ;
598+ }
599+
582600 private captureSessionModelsMetadata ( sessionId : string , response : unknown ) : void {
583601 if ( ! isObject ( response ) ) return ;
584602
@@ -588,16 +606,17 @@ export class AcpSdkBackend implements AgentBackend {
588606 const nestedList = nested ?. availableModels ;
589607 const nestedCurrent = nested ?. currentModelId ;
590608
609+ const configModelOption = this . extractModelConfigOption ( response ) ;
591610 const rawModels = Array . isArray ( directList )
592611 ? directList
593612 : Array . isArray ( nestedList )
594613 ? nestedList
595- : null ;
614+ : configModelOption ?. options ?? null ;
596615 const rawCurrent = typeof directCurrent === 'string'
597616 ? directCurrent
598617 : typeof nestedCurrent === 'string'
599618 ? nestedCurrent
600- : null ;
619+ : configModelOption ?. currentValue ?? null ;
601620
602621 if ( rawModels === null && rawCurrent === null ) {
603622 return ;
@@ -607,7 +626,7 @@ export class AcpSdkBackend implements AgentBackend {
607626 if ( Array . isArray ( rawModels ) ) {
608627 for ( const entry of rawModels ) {
609628 if ( ! isObject ( entry ) ) continue ;
610- const modelId = asString ( entry . modelId ) ;
629+ const modelId = asString ( entry . modelId ) ?? asString ( entry . value ) ;
611630 if ( ! modelId ) continue ;
612631 const name = asString ( entry . name ) ?? undefined ;
613632 availableModels . push ( name ? { modelId, name } : { modelId } ) ;
0 commit comments