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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class AgentWithMemoryTest {
@Test
public void agentRemembersUserNameWithMemoryTool() throws Exception {
String userId = "test-user";
String agentName = "test-agent";
String agentName = "test_agent";

Part functionCall =
Part.builder()
Expand Down Expand Up @@ -101,7 +101,7 @@ public void agentRemembersUserNameWithMemoryTool() throws Exception {
Session updatedSession =
runner
.sessionService()
.getSession("test-agent", userId, sessionId, Optional.empty())
.getSession("test_agent", userId, sessionId, Optional.empty())
.blockingGet();

// Save the updated session to memory so we can bring it up on the next request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,13 +659,13 @@ public void baseAgentRunAsync_propagatesContext() throws InterruptedException {
@Test
public void runnerRunAsync_propagatesContext() throws InterruptedException {
BaseAgent agent = new TestAgent();
Runner runner = Runner.builder().agent(agent).appName("test-app").build();
Runner runner = Runner.builder().agent(agent).appName("test_app").build();
Span parentSpan = tracer.spanBuilder("parent").startSpan();
try (Scope s = parentSpan.makeCurrent()) {
Session session =
runner
.sessionService()
.createSession(new SessionKey("test-app", "test-user", "test-session"))
.createSession(new SessionKey("test_app", "test-user", "test-session"))
.blockingGet();
Content newMessage = Content.fromParts(Part.fromText("hi"));
RunConfig runConfig = RunConfig.builder().build();
Expand All @@ -689,13 +689,13 @@ public void runnerRunAsync_propagatesContext() throws InterruptedException {
@Test
public void runnerRunLive_propagatesContext() throws InterruptedException {
BaseAgent agent = new TestAgent();
Runner runner = Runner.builder().agent(agent).appName("test-app").build();
Runner runner = Runner.builder().agent(agent).appName("test_app").build();
Span parentSpan = tracer.spanBuilder("parent").startSpan();
try (Scope s = parentSpan.makeCurrent()) {
Session session =
runner
.sessionService()
.createSession("test-app", "test-user", (Map<String, Object>) null, "test-session")
.createSession("test_app", "test-user", (Map<String, Object>) null, "test-session")
.blockingGet();
Content newMessage = Content.fromParts(Part.fromText("hi"));
RunConfig runConfig = RunConfig.builder().build();
Expand Down Expand Up @@ -744,7 +744,9 @@ private SpanData findSpanByName(String name) {

private InvocationContext buildInvocationContext() {
Session session =
sessionService.createSession("test-app", "test-user", null, "test-session").blockingGet();
sessionService
.createSession("test_app", "test-user", (Map<String, Object>) null, "test-session")
.blockingGet();
return InvocationContext.builder()
.sessionService(sessionService)
.session(session)
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/com/google/adk/testing/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static InvocationContext createInvocationContext(BaseAgent agent, RunConf
.artifactService(new InMemoryArtifactService())
.invocationId("invocationId")
.agent(agent)
.session(sessionService.createSession("test-app", "test-user").blockingGet())
.session(sessionService.createSession("test_app", "test-user").blockingGet())
.userContent(Content.fromParts(Part.fromText("user content")))
.runConfig(runConfig)
.build();
Expand Down
28 changes: 14 additions & 14 deletions core/src/test/java/com/google/adk/tools/AgentToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void declaration_withInputSchema_returnsDeclarationWithSchema() {
AgentTool agentTool =
AgentTool.create(
createTestAgentBuilder(createTestLlm(LlmResponse.builder().build()))
.name("agent name")
.name("agent_name")
.description("agent description")
.inputSchema(inputSchema)
.build());
Expand All @@ -153,7 +153,7 @@ public void declaration_withInputSchema_returnsDeclarationWithSchema() {
assertThat(declaration)
.isEqualTo(
FunctionDeclaration.builder()
.name("agent name")
.name("agent_name")
.description("agent description")
.parameters(inputSchema)
.build());
Expand All @@ -164,7 +164,7 @@ public void declaration_withoutInputSchema_returnsDeclarationWithRequestParamete
AgentTool agentTool =
AgentTool.create(
createTestAgentBuilder(createTestLlm(LlmResponse.builder().build()))
.name("agent name")
.name("agent_name")
.description("agent description")
.build());

Expand All @@ -173,7 +173,7 @@ public void declaration_withoutInputSchema_returnsDeclarationWithRequestParamete
assertThat(declaration)
.isEqualTo(
FunctionDeclaration.builder()
.name("agent name")
.name("agent_name")
.description("agent description")
.parameters(
Schema.builder()
Expand All @@ -200,7 +200,7 @@ public void call_withInputSchema_invalidInput_throwsException() throws Exception
.build();
LlmAgent testAgent =
createTestAgentBuilder(createTestLlm(LlmResponse.builder().build()))
.name("agent name")
.name("agent_name")
.description("agent description")
.inputSchema(inputSchema)
.build();
Expand Down Expand Up @@ -256,7 +256,7 @@ public void call_withOutputSchema_invalidOutput_throwsException() throws Excepti
"{\"is_valid\": \"invalid type\", "
+ "\"message\": \"success\"}")))
.build()))
.name("agent name")
.name("agent_name")
.description("agent description")
.outputSchema(outputSchema)
.build();
Expand Down Expand Up @@ -301,7 +301,7 @@ public void call_withInputAndOutputSchema_successful() throws Exception {
Part.fromText(
"{\"is_valid\": true, " + "\"message\": \"success\"}")))
.build()))
.name("agent name")
.name("agent_name")
.description("agent description")
.inputSchema(inputSchema)
.outputSchema(outputSchema)
Expand Down Expand Up @@ -332,7 +332,7 @@ public void call_withoutSchema_returnsConcatenatedTextFromLastEvent() throws Exc
Part.fromText("First text part. "),
Part.fromText("Second text part.")))
.build())))
.name("agent name")
.name("agent_name")
.description("agent description")
.build();
AgentTool agentTool = AgentTool.create(testAgent);
Expand All @@ -358,7 +358,7 @@ public void call_withThoughts_returnsOnlyNonThoughtText() throws Exception {
.build())
.build());
LlmAgent testAgent =
createTestAgentBuilder(testLlm).name("agent name").description("agent description").build();
createTestAgentBuilder(testLlm).name("agent_name").description("agent description").build();
AgentTool agentTool = AgentTool.create(testAgent);
ToolContext toolContext = createToolContext(testAgent);

Expand All @@ -373,7 +373,7 @@ public void call_emptyModelResponse_returnsEmptyMap() throws Exception {
LlmAgent testAgent =
createTestAgentBuilder(
createTestLlm(LlmResponse.builder().content(Content.builder().build()).build()))
.name("agent name")
.name("agent_name")
.description("agent description")
.build();
AgentTool agentTool = AgentTool.create(testAgent);
Expand All @@ -394,7 +394,7 @@ public void call_withInputSchema_argsAreSentToAgent() throws Exception {
.build());
LlmAgent testAgent =
createTestAgentBuilder(testLlm)
.name("agent name")
.name("agent_name")
.description("agent description")
.inputSchema(
Schema.builder()
Expand Down Expand Up @@ -422,7 +422,7 @@ public void call_withoutInputSchema_requestIsSentToAgent() throws Exception {
.content(Content.fromParts(Part.fromText("test response")))
.build());
LlmAgent testAgent =
createTestAgentBuilder(testLlm).name("agent name").description("agent description").build();
createTestAgentBuilder(testLlm).name("agent_name").description("agent description").build();
AgentTool agentTool = AgentTool.create(testAgent);
ToolContext toolContext = createToolContext(testAgent);

Expand All @@ -447,7 +447,7 @@ public void call_withStateDeltaInResponse_propagatesStateDelta() throws Exceptio
.build());
LlmAgent testAgent =
createTestAgentBuilder(testLlm)
.name("agent name")
.name("agent_name")
.description("agent description")
.afterAgentCallback(afterAgentCallback)
.build();
Expand Down Expand Up @@ -477,7 +477,7 @@ public void call_withSkipSummarizationAndStateDelta_propagatesStateAndSetsSkipSu
.build());
LlmAgent testAgent =
createTestAgentBuilder(testLlm)
.name("agent name")
.name("agent_name")
.description("agent description")
.afterAgentCallback(afterAgentCallback)
.build();
Expand Down
Loading