Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions agent/llmagent/llmagent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"google.golang.org/adk/tool/functiontool"
)

const modelName = "gemini-2.0-flash"
const modelName = "gemini-2.5-flash"

//go:generate go test -httprecord=Test

Expand Down Expand Up @@ -696,7 +696,13 @@ func TestInstructionProvider(t *testing.T) {
genai.NewContentFromText("user input", genai.RoleUser),
},
Config: &genai.GenerateContentConfig{
SystemInstruction: genai.NewContentFromText("instruction custom_value test", genai.RoleUser),
SystemInstruction: &genai.Content{
Parts: []*genai.Part{
genai.NewPartFromText("instruction custom_value test"),
genai.NewPartFromText(`You are an agent. Your internal name is "test_agent".`),
},
Role: genai.RoleUser,
},
},
},
},
Expand All @@ -723,7 +729,13 @@ func TestInstructionProvider(t *testing.T) {
genai.NewContentFromText("user input", genai.RoleUser),
},
Config: &genai.GenerateContentConfig{
SystemInstruction: genai.NewContentFromText("instruction provider template {var} not evaluated", genai.RoleUser),
SystemInstruction: &genai.Content{
Parts: []*genai.Part{
genai.NewPartFromText("instruction provider template {var} not evaluated"),
genai.NewPartFromText(`You are an agent. Your internal name is "test_agent".`),
},
Role: genai.RoleUser,
},
},
},
},
Expand All @@ -750,7 +762,13 @@ func TestInstructionProvider(t *testing.T) {
genai.NewContentFromText("user input", genai.RoleUser),
},
Config: &genai.GenerateContentConfig{
SystemInstruction: genai.NewContentFromText("global instruction provider template {var} not evaluated", genai.RoleUser),
SystemInstruction: &genai.Content{
Parts: []*genai.Part{
genai.NewPartFromText("global instruction provider template {var} not evaluated"),
genai.NewPartFromText(`You are an agent. Your internal name is "test_agent".`),
},
Role: genai.RoleUser,
},
},
},
},
Expand Down Expand Up @@ -783,6 +801,7 @@ func TestInstructionProvider(t *testing.T) {
Parts: []*genai.Part{
genai.NewPartFromText("global instruction provider {var}"),
genai.NewPartFromText("instruction provider {var}"),
genai.NewPartFromText(`You are an agent. Your internal name is "test_agent".`),
},
Role: genai.RoleUser,
},
Expand Down
16 changes: 8 additions & 8 deletions agent/llmagent/testdata/TestFunctionTool.httprr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
httprr trace v1
824 1140
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent HTTP/1.1
931 1140
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent HTTP/1.1
Host: generativelanguage.googleapis.com
User-Agent: Go-http-client/1.1
Content-Length: 592
Content-Length: 699
Content-Type: application/json

{"contents":[{"parts":[{"text":"what is the sum of 1 + 2?"}],"role":"user"}],"generationConfig":{},"systemInstruction":{"parts":[{"text":"output ONLY the result computed by the provided function"}],"role":"user"},"tools":[{"functionDeclarations":[{"description":"computes the sum of two numbers","name":"sum","parametersJsonSchema":{"additionalProperties":false,"properties":{"a":{"type":"integer"},"b":{"type":"integer"}},"required":["a","b"],"type":"object"},"responseJsonSchema":{"additionalProperties":false,"properties":{"sum":{"type":"integer"}},"required":["sum"],"type":"object"}}]}]}HTTP/2.0 200 OK
{"contents":[{"parts":[{"text":"what is the sum of 1 + 2?"}],"role":"user"}],"generationConfig":{},"systemInstruction":{"parts":[{"text":"output ONLY the result computed by the provided function"},{"text":"You are an agent. Your internal name is \"agent\". The description about you is \"math agent\"."}],"role":"user"},"tools":[{"functionDeclarations":[{"description":"computes the sum of two numbers","name":"sum","parametersJsonSchema":{"additionalProperties":false,"properties":{"a":{"type":"integer"},"b":{"type":"integer"}},"required":["a","b"],"type":"object"},"responseJsonSchema":{"additionalProperties":false,"properties":{"sum":{"type":"integer"}},"required":["sum"],"type":"object"}}]}]}HTTP/2.0 200 OK
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Content-Type: application/json; charset=UTF-8
Date: Fri, 05 Sep 2025 16:15:32 GMT
Expand Down Expand Up @@ -60,14 +60,14 @@ X-Xss-Protection: 0
"modelVersion": "gemini-2.0-flash",
"responseId": "pAy7aJbkIe2m1MkPgbz0iAo"
}
987 1007
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent HTTP/1.1
1094 1007
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent HTTP/1.1
Host: generativelanguage.googleapis.com
User-Agent: Go-http-client/1.1
Content-Length: 755
Content-Length: 862
Content-Type: application/json

{"contents":[{"parts":[{"text":"what is the sum of 1 + 2?"}],"role":"user"},{"parts":[{"functionCall":{"args":{"a":1,"b":2},"name":"sum"}}],"role":"model"},{"parts":[{"functionResponse":{"name":"sum","response":{"sum":3}}}],"role":"user"}],"generationConfig":{},"systemInstruction":{"parts":[{"text":"output ONLY the result computed by the provided function"}],"role":"user"},"tools":[{"functionDeclarations":[{"description":"computes the sum of two numbers","name":"sum","parametersJsonSchema":{"additionalProperties":false,"properties":{"a":{"type":"integer"},"b":{"type":"integer"}},"required":["a","b"],"type":"object"},"responseJsonSchema":{"additionalProperties":false,"properties":{"sum":{"type":"integer"}},"required":["sum"],"type":"object"}}]}]}HTTP/2.0 200 OK
{"contents":[{"parts":[{"text":"what is the sum of 1 + 2?"}],"role":"user"},{"parts":[{"functionCall":{"args":{"a":1,"b":2},"name":"sum"}}],"role":"model"},{"parts":[{"functionResponse":{"name":"sum","response":{"sum":3}}}],"role":"user"}],"generationConfig":{},"systemInstruction":{"parts":[{"text":"output ONLY the result computed by the provided function"},{"text":"You are an agent. Your internal name is \"agent\". The description about you is \"math agent\"."}],"role":"user"},"tools":[{"functionDeclarations":[{"description":"computes the sum of two numbers","name":"sum","parametersJsonSchema":{"additionalProperties":false,"properties":{"a":{"type":"integer"},"b":{"type":"integer"}},"required":["a","b"],"type":"object"},"responseJsonSchema":{"additionalProperties":false,"properties":{"sum":{"type":"integer"}},"required":["sum"],"type":"object"}}]}]}HTTP/2.0 200 OK
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Content-Type: application/json; charset=UTF-8
Date: Fri, 05 Sep 2025 16:15:33 GMT
Expand Down
6 changes: 3 additions & 3 deletions agent/llmagent/testdata/TestLLMAgentStreamingModeSSE.httprr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
httprr trace v1
537 8297
656 8297
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse HTTP/1.1
Host: generativelanguage.googleapis.com
User-Agent: Go-http-client/1.1
Content-Length: 291
Content-Length: 410
Content-Type: application/json

{"contents":[{"parts":[{"text":"What is the sum of the first 50 prime numbers?"}],"role":"user"}],"generationConfig":{"thinkingConfig":{"includeThoughts":true}},"systemInstruction":{"parts":[{"text":"Think deep. Always double check the answer before making the conclusion."}],"role":"user"}}HTTP/2.0 200 OK
{"contents":[{"parts":[{"text":"What is the sum of the first 50 prime numbers?"}],"role":"user"}],"generationConfig":{"thinkingConfig":{"includeThoughts":true}},"systemInstruction":{"parts":[{"text":"Think deep. Always double check the answer before making the conclusion."},{"text":"You are an agent. Your internal name is \"calculator\". The description about you is \"calculating agent\"."}],"role":"user"}}HTTP/2.0 200 OK
Connection: close
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Content-Disposition: attachment
Expand Down
8 changes: 4 additions & 4 deletions agent/llmagent/testdata/TestLLMAgent_healthy_backend.httprr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
httprr trace v1
508 945
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent HTTP/1.1
634 945
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent HTTP/1.1
Host: generativelanguage.googleapis.com
User-Agent: Go-http-client/1.1
Content-Length: 276
Content-Length: 402
Content-Type: application/json

{"contents":[{"parts":[{"text":"Handle the requests as specified in the System Instruction."}],"role":"user"}],"generationConfig":{},"systemInstruction":{"parts":[{"text":"Answer as precisely as possible."},{"text":"Roll the dice and report only the result."}],"role":"user"}}HTTP/2.0 200 OK
{"contents":[{"parts":[{"text":"Handle the requests as specified in the System Instruction."}],"role":"user"}],"generationConfig":{},"systemInstruction":{"parts":[{"text":"Answer as precisely as possible."},{"text":"Roll the dice and report only the result."},{"text":"You are an agent. Your internal name is \"hello_world_agent\". The description about you is \"hello world agent\"."}],"role":"user"}}HTTP/2.0 200 OK
Content-Type: application/json; charset=UTF-8
Date: Mon, 29 Sep 2025 08:03:49 GMT
Server: scaffolding on HTTPServer2
Expand Down
Loading
Loading