Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
74e8464
feat: add end to end integration test
JackYPCOnline Jun 9, 2025
6910700
Merge branch 'strands-agents:main' into integration-test
JackYPCOnline Jun 10, 2025
42656ba
feat: add integration tests for the package
JackYPCOnline Jun 11, 2025
f24b8fe
feat: remove old test
JackYPCOnline Jun 11, 2025
b4d3cfc
refactor: refactor the test code with patch api instead of monkeypatch
JackYPCOnline Jun 12, 2025
991e70d
feat: add STRANDS_ANTHROPIC_BETA environment variable (#34)
awsarron Jun 18, 2025
a4fed3c
Windows: Remove cron tool + document missing tools when on windows (#33)
zastrowm Jun 19, 2025
88c305d
udpate agent system_prompt reference (#35)
Unshure Jul 3, 2025
2eff5dc
chore: explicitly set load_tools_from_directory on Agent initilizatio…
dbschmigelski Jul 11, 2025
68e2c50
Update builder with updates from 0.3.0 SDK (#39)
zastrowm Jul 11, 2025
577e9f0
chore: Remove Preview (#40)
yonib05 Jul 15, 2025
ac7d801
deps: bump strangs-agents to v1.0.0 (#41)
jer96 Jul 15, 2025
e30a6e9
build(pyproject): update development status classifier (#42)
awsarron Jul 16, 2025
0702a52
Use strands logo that looks good in dark & light mode (#44)
zastrowm Jul 21, 2025
09a19a9
fix: refactor some tests
JackYPCOnline Aug 1, 2025
0dd5163
Merge branch 'strands-agents:main' into integration-test
JackYPCOnline Aug 1, 2025
b0c5f7e
fix: refactor tests code
JackYPCOnline Aug 4, 2025
c149f5b
fix: make tests more accurate
JackYPCOnline Aug 14, 2025
629e722
fix: remove test_custom_load_from_file to avoiding text based respons…
JackYPCOnline Aug 14, 2025
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
Empty file added __init__.py
Empty file.
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ test = [
"hatch test --cover --cov-report term --cov-report html --cov-report xml {args}"
]

test-integ = [
"hatch test tests-integ {args}"
]

[tool.mypy]
python_version = "3.10"
warn_return_any = true
Expand All @@ -160,7 +164,7 @@ ignore_missing_imports = false

[tool.ruff]
line-length = 120
include = ["src/**/*.py", "tests/**/*.py", "tools/**/*.py"]
include = ["src/**/*.py", "tests/**/*.py", "tools/**/*.py","tests-integ/**/*.py"]

[tool.ruff.lint]
select = [
Expand Down
Empty file added tests-integ/__init__.py
Empty file.
70 changes: 70 additions & 0 deletions tests-integ/end_to_end_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import re

import pytest
from strands.agent import Agent
from strands.models import BedrockModel


@pytest.fixture
def bedrock_model():
return BedrockModel(
model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
streaming=True,
)


def extract_code_from_response(response):
"""Extract Python code blocks from the agent's response."""
code_pattern = r"```python\s*(.*?)\s*```"
matches = re.findall(code_pattern, str(response), re.DOTALL)
if matches:
return matches[0].strip()
return None


def test_agent_creates_calculator_tool(tmp_path, monkeypatch, bedrock_model):
"""End-to-end test: Ask agent to create a tool, validate it, then delete it."""
tools_dir = tmp_path / "tools"
tools_dir.mkdir(parents=True)
monkeypatch.setenv("STRANDS_TOOLS_DIR", str(tools_dir))

tool_path = tools_dir / "calculator_tool.py"

try:
creator_agent = Agent(model=bedrock_model)
prompt = """
Create a Python tool named calculator_tool that can perform basic arithmetic operations.
The tool should:
1. Take two numbers and an operator ('+', '-', '*', '/')
2. Return the result of the operation
3. Include proper docstrings and error handling
4. Be compatible with the Strands SDK tool system
Provide only the Python code with no additional explanation.
"""
creation_response = creator_agent(prompt)

tool_code = extract_code_from_response(creation_response)
assert tool_code is not None, "Failed to extract tool code from agent response"

with open(tool_path, "w") as f:
f.write(tool_code)
assert tool_path.exists(), f"Tool file was not created at {tool_path}"

agent = Agent(model=bedrock_model, tools=None, load_tools_from_directory=True)

test_cases = [
("What is 1 + 2?", "3"),
("Calculate 2 - 1", "1"),
("What is 1 multiplied by 5?", "5"),
("Divide 20 by 4", "5"),
]

for question, expected in test_cases:
response = agent(question)
response_str = str(response).lower()
assert expected.lower() in response_str, f"Failed to find '{expected}' in response to '{question}'"

finally:
if tool_path.exists():
tool_path.unlink()
Loading