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
14 changes: 0 additions & 14 deletions core/src/main/java/com/google/adk/agents/LlmAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -631,20 +631,6 @@ protected void validate() {
this.disallowTransferToParent = true;
this.disallowTransferToPeers = true;
}

if (this.subAgents != null && !this.subAgents.isEmpty()) {
throw new IllegalArgumentException(
"Invalid config for agent "
+ this.name
+ ": if outputSchema is set, subAgents must be empty to disable agent"
+ " transfer.");
}
if (this.toolsUnion != null && !this.toolsUnion.isEmpty()) {
throw new IllegalArgumentException(
"Invalid config for agent "
+ this.name
+ ": if outputSchema is set, tools must be empty.");
}
}
}

Expand Down
73 changes: 0 additions & 73 deletions core/src/test/java/com/google/adk/agents/LlmAgentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

import com.google.adk.agents.Callbacks.AfterModelCallback;
import com.google.adk.agents.Callbacks.AfterToolCallback;
Expand All @@ -50,9 +49,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.genai.types.Content;
import com.google.genai.types.FunctionDeclaration;
import com.google.genai.types.Part;
import com.google.genai.types.Schema;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
Expand All @@ -61,7 +58,6 @@
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.core.Single;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
Expand Down Expand Up @@ -211,75 +207,6 @@ public void run_withToolsAndMaxSteps_stopsAfterMaxSteps() {
assertEqualIgnoringFunctionIds(events.get(3).content().get(), expectedFunctionResponseContent);
}

@Test
public void build_withOutputSchemaAndTools_throwsIllegalArgumentException() {
BaseTool tool =
new BaseTool("test_tool", "test_description") {
@Override
public Optional<FunctionDeclaration> declaration() {
return Optional.empty();
}
};

Schema outputSchema =
Schema.builder()
.type("OBJECT")
.properties(ImmutableMap.of("status", Schema.builder().type("STRING").build()))
.required(ImmutableList.of("status"))
.build();

// Expecting an IllegalArgumentException when building the agent
IllegalArgumentException exception =
assertThrows(
IllegalArgumentException.class,
() ->
LlmAgent.builder() // Use the agent builder directly
.name("agent with invalid tool config")
.outputSchema(outputSchema) // Set the output schema
.tools(ImmutableList.of(tool)) // Set tools (this should cause the error)
.build()); // Attempt to build the agent

assertThat(exception)
.hasMessageThat()
.contains(
"Invalid config for agent agent with invalid tool config: if outputSchema is set, tools"
+ " must be empty");
}

@Test
public void build_withOutputSchemaAndSubAgents_throwsIllegalArgumentException() {
ImmutableList<BaseAgent> subAgents =
ImmutableList.of(
createTestAgentBuilder(createTestLlm(LlmResponse.builder().build()))
.name("test_sub_agent")
.description("test_sub_agent_description")
.build());

Schema outputSchema =
Schema.builder()
.type("OBJECT")
.properties(ImmutableMap.of("status", Schema.builder().type("STRING").build()))
.required(ImmutableList.of("status"))
.build();

// Expecting an IllegalArgumentException when building the agent
IllegalArgumentException exception =
assertThrows(
IllegalArgumentException.class,
() ->
LlmAgent.builder() // Use the agent builder directly
.name("agent with invalid tool config")
.outputSchema(outputSchema) // Set the output schema
.subAgents(subAgents) // Set subAgents (this should cause the error)
.build()); // Attempt to build the agent

assertThat(exception)
.hasMessageThat()
.contains(
"Invalid config for agent agent with invalid tool config: if outputSchema is set,"
+ " subAgents must be empty to disable agent transfer.");
}

@Test
public void testBuild_withNullInstruction_setsInstructionToEmptyString() {
LlmAgent agent =
Expand Down
Loading