Skip to content

Commit a70b50a

Browse files
committed
fix: add e2e tests for anthropic thinking feature
1 parent e99b028 commit a70b50a

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from google.adk import Agent
16+
from google.adk.models.anthropic_llm import AnthropicLlm
17+
from google.adk.planners.built_in_planner import BuiltInPlanner
18+
from google.genai import types
19+
20+
21+
def check_prime(nums: list[int]) -> str:
22+
"""Check if a given list of numbers are prime.
23+
24+
Args:
25+
nums: The list of numbers to check.
26+
27+
Returns:
28+
A str indicating which numbers are prime.
29+
"""
30+
primes = set()
31+
for number in nums:
32+
number = int(number)
33+
if number <= 1:
34+
continue
35+
is_prime = True
36+
for i in range(2, int(number**0.5) + 1):
37+
if number % i == 0:
38+
is_prime = False
39+
break
40+
if is_prime:
41+
primes.add(number)
42+
return (
43+
"No prime numbers found."
44+
if not primes
45+
else f"{', '.join(str(num) for num in sorted(primes))} are prime numbers."
46+
)
47+
48+
49+
root_agent = Agent(
50+
model=AnthropicLlm(model="claude-sonnet-4-6"),
51+
name="anthropic_thinking_agent",
52+
description="An agent that uses Claude extended thinking via Vertex AI.",
53+
instruction="""
54+
You are a helpful assistant. Use your reasoning carefully before answering.
55+
When asked to check prime numbers, use the check_prime tool.
56+
""",
57+
tools=[check_prime],
58+
planner=BuiltInPlanner(
59+
thinking_config=types.ThinkingConfig(thinking_budget=5000),
60+
),
61+
)

0 commit comments

Comments
 (0)