@@ -536,6 +536,61 @@ func TestValidPrompt(t *testing.T) {
536536 },
537537 },
538538 },
539+ {
540+ name : "execute with tools overriding prompt-level tools" ,
541+ model : model ,
542+ config : & GenerationCommonConfig {Temperature : 11 },
543+ inputType : HelloPromptInput {},
544+ systemText : "say hello" ,
545+ promptText : "my name is foo" ,
546+ tools : []ToolRef {testTool (reg , "promptTool" )},
547+ input : HelloPromptInput {Name : "foo" },
548+ executeOptions : []PromptExecuteOption {
549+ WithInput (HelloPromptInput {Name : "foo" }),
550+ WithTools (testTool (reg , "executeOverrideTool" )),
551+ },
552+ wantTextOutput : "Echo: system: tool: say hello; my name is foo; ; Bar; ; config: {\n \" temperature\" : 11\n }; context: null" ,
553+ wantGenerated : & ModelRequest {
554+ Config : & GenerationCommonConfig {
555+ Temperature : 11 ,
556+ },
557+ Output : & ModelOutputConfig {
558+ ContentType : "text/plain" ,
559+ },
560+ ToolChoice : "required" ,
561+ Messages : []* Message {
562+ {
563+ Role : RoleSystem ,
564+ Content : []* Part {NewTextPart ("say hello" )},
565+ },
566+ {
567+ Role : RoleUser ,
568+ Content : []* Part {NewTextPart ("my name is foo" )},
569+ },
570+ {
571+ Role : RoleModel ,
572+ Content : []* Part {NewToolRequestPart (& ToolRequest {Name : "executeOverrideTool" , Input : map [string ]any {"Test" : "Bar" }})},
573+ },
574+ {
575+ Role : RoleTool ,
576+ Content : []* Part {NewToolResponsePart (& ToolResponse {Output : "Bar" })},
577+ },
578+ },
579+ Tools : []* ToolDefinition {
580+ {
581+ Name : "executeOverrideTool" ,
582+ Description : "use when need to execute a test" ,
583+ InputSchema : map [string ]any {
584+ "additionalProperties" : bool (false ),
585+ "properties" : map [string ]any {"Test" : map [string ]any {"type" : string ("string" )}},
586+ "required" : []any {string ("Test" )},
587+ "type" : string ("object" ),
588+ },
589+ OutputSchema : map [string ]any {"type" : string ("string" )},
590+ },
591+ },
592+ },
593+ },
539594 }
540595
541596 cmpPart := func (a , b * Part ) bool {
0 commit comments