@@ -243,8 +243,6 @@ export interface FunctionDeclaration<Args extends Record<string, unknown>, Retur
243243 } ) => Promise < FunctionCallHandlerResult < ReturnType > > ;
244244}
245245
246- const OBSERVATION_PREFIX = 'OBSERVATION: ' ;
247-
248246interface AidaFetchResult {
249247 text ?: string ;
250248 functionCall ?: Host . AidaClient . AidaFunctionCallResponse ;
@@ -364,7 +362,7 @@ export abstract class AiAgent<T> {
364362 function validTemperature ( temperature : number | undefined ) : number | undefined {
365363 return typeof temperature === 'number' && temperature >= 0 ? temperature : undefined ;
366364 }
367- const enableAidaFunctionCalling = declarations . length && ! this . functionCallEmulationEnabled ;
365+ const enableAidaFunctionCalling = declarations . length ;
368366 const userTier = Host . AidaClient . convertToUserTierEnum ( this . userTier ) ;
369367 const preamble = userTier === Host . AidaClient . UserTier . TESTERS ? this . preamble : undefined ;
370368 const facts = Array . from ( this . #facts) ;
@@ -437,20 +435,6 @@ export abstract class AiAgent<T> {
437435 this . #functionDeclarations. clear ( ) ;
438436 }
439437
440- protected formatParsedAnswer ( { answer} : ParsedAnswer ) : string {
441- return answer ;
442- }
443-
444- /**
445- * Special mode for StylingAgent that turns custom text output into a
446- * function call.
447- */
448- protected functionCallEmulationEnabled = false ;
449- protected emulateFunctionCall ( _aidaResponse : Host . AidaClient . DoConversationResponse ) :
450- Host . AidaClient . AidaFunctionCallResponse | 'no-function-call' | 'wait-for-completion' {
451- throw new Error ( 'Unexpected emulateFunctionCall. Only StylingAgent implements function call emulation' ) ;
452- }
453-
454438 async *
455439 run ( initialQuery : string , options : {
456440 selected : ConversationContext < T > | null ,
@@ -537,7 +521,7 @@ export abstract class AiAgent<T> {
537521 }
538522 this . #history. push ( {
539523 parts : [ {
540- text : this . formatParsedAnswer ( parsedResponse ) ,
524+ text : parsedResponse . answer ,
541525 } ] ,
542526 role : Host . AidaClient . Role . MODEL ,
543527 } ) ;
@@ -559,15 +543,13 @@ export abstract class AiAgent<T> {
559543 yield this . #createErrorResponse( ErrorType . ABORT ) ;
560544 break ;
561545 }
562- query = this . functionCallEmulationEnabled ? { text : OBSERVATION_PREFIX + result . result } : {
546+ query = {
563547 functionResponse : {
564548 name : functionCall . name ,
565549 response : result ,
566550 } ,
567551 } ;
568- request = this . buildRequest (
569- query ,
570- this . functionCallEmulationEnabled ? Host . AidaClient . Role . USER : Host . AidaClient . Role . ROLE_UNSPECIFIED ) ;
552+ request = this . buildRequest ( query , Host . AidaClient . Role . ROLE_UNSPECIFIED ) ;
571553 } catch {
572554 yield this . #createErrorResponse( ErrorType . UNKNOWN ) ;
573555 break ;
@@ -591,26 +573,15 @@ export abstract class AiAgent<T> {
591573 if ( ! call ) {
592574 throw new Error ( `Function ${ name } is not found.` ) ;
593575 }
594- if ( this . functionCallEmulationEnabled ) {
595- if ( ! call . displayInfoFromArgs ) {
596- throw new Error ( 'functionCallEmulationEnabled requires all functions to provide displayInfoFromArgs' ) ;
597- }
598- // Emulated function calls are formatted as text.
599- this . #history. push ( {
600- parts : [ { text : this . #formatParsedStep( call . displayInfoFromArgs ( args ) ) } ] ,
601- role : Host . AidaClient . Role . MODEL ,
602- } ) ;
603- } else {
604- this . #history. push ( {
605- parts : [ {
606- functionCall : {
607- name,
608- args,
609- } ,
610- } ] ,
611- role : Host . AidaClient . Role . MODEL ,
612- } ) ;
613- }
576+ this . #history. push ( {
577+ parts : [ {
578+ functionCall : {
579+ name,
580+ args,
581+ } ,
582+ } ] ,
583+ role : Host . AidaClient . Role . MODEL ,
584+ } ) ;
614585
615586 let code ;
616587 if ( call . displayInfoFromArgs ) {
@@ -723,21 +694,6 @@ export abstract class AiAgent<T> {
723694 break ;
724695 }
725696
726- if ( this . functionCallEmulationEnabled ) {
727- const emulatedFunctionCall = this . emulateFunctionCall ( aidaResponse ) ;
728- if ( emulatedFunctionCall === 'wait-for-completion' ) {
729- continue ;
730- }
731- if ( emulatedFunctionCall !== 'no-function-call' ) {
732- yield {
733- rpcId,
734- functionCall : emulatedFunctionCall ,
735- completed : true ,
736- } ;
737- break ;
738- }
739- }
740-
741697 rpcId = aidaResponse . metadata . rpcGlobalId ?? rpcId ;
742698 yield {
743699 rpcId,
@@ -759,23 +715,6 @@ export abstract class AiAgent<T> {
759715 }
760716 }
761717
762- #formatParsedStep( step : ParsedStep ) : string {
763- let text = '' ;
764- if ( step . thought ) {
765- text = `THOUGHT: ${ step . thought } ` ;
766- }
767- if ( step . title ) {
768- text += `\nTITLE: ${ step . title } ` ;
769- }
770- if ( step . action ) {
771- text += `\nACTION
772- ${ step . action }
773- STOP` ;
774- }
775-
776- return text ;
777- }
778-
779718 #removeLastRunParts( ) : void {
780719 this . #history. splice ( this . #history. findLastIndex ( item => {
781720 return item . role === Host . AidaClient . Role . USER ;
0 commit comments