Skip to content

Commit 0eb2f2b

Browse files
committed
integ tests
1 parent d135ca5 commit 0eb2f2b

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

tests_integ/models/test_model_bedrock.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,19 @@ def test_redacted_content_handling():
267267
assert "reasoningContent" in result.message["content"][0]
268268
assert "redactedContent" in result.message["content"][0]["reasoningContent"]
269269
assert isinstance(result.message["content"][0]["reasoningContent"]["redactedContent"], bytes)
270+
271+
272+
def test_multi_prompt_system_content():
273+
"""Test multi-prompt system content blocks."""
274+
system_prompt_content = [
275+
{"text": "You are a helpful assistant."},
276+
{"text": "Always be concise."},
277+
{"text": "End responses with 'Done.'"}
278+
]
279+
280+
agent = Agent(
281+
system_prompt=system_prompt_content,
282+
load_tools_from_directory=False
283+
)
284+
result = agent("Hello!")
285+
# just verifying there is no failure

tests_integ/models/test_model_openai.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,16 @@ def test_rate_limit_throttling_integration_no_retries(model):
221221
# Verify it's a rate limit error
222222
error_message = str(exc_info.value).lower()
223223
assert "rate limit" in error_message or "tokens per min" in error_message
224+
225+
226+
def test_content_blocks_handling(model):
227+
"""Test that content blocks are handled properly without failures."""
228+
content = [
229+
{"text": "What is 2+2?"},
230+
{"text": "Please be brief."}
231+
]
232+
233+
agent = Agent(model=model, load_tools_from_directory=False)
234+
result = agent(content)
235+
236+
assert "4" in result.message["content"][0]["text"]

tests_integ/test_bedrock_cache_point.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,30 @@ def cache_point_callback_handler(**kwargs):
2929
agent = Agent(messages=messages, callback_handler=cache_point_callback_handler, load_tools_from_directory=False)
3030
agent("What is favorite color?")
3131
assert cache_point_usage > 0
32+
33+
34+
def test_bedrock_multi_prompt_cache_point():
35+
"""Test multi-prompt system with cache point."""
36+
system_prompt_content = [
37+
{"text": "You are a helpful assistant." * 500}, # Long text for cache
38+
{"cachePoint": {"type": "default"}},
39+
{"text": "Always respond with enthusiasm!"}
40+
]
41+
42+
cache_point_usage = 0
43+
44+
def cache_point_callback_handler(**kwargs):
45+
nonlocal cache_point_usage
46+
if "event" in kwargs and kwargs["event"] and "metadata" in kwargs["event"] and kwargs["event"]["metadata"]:
47+
metadata = kwargs["event"]["metadata"]
48+
if "usage" in metadata and metadata["usage"]:
49+
if "cacheReadInputTokens" in metadata["usage"] or "cacheWriteInputTokens" in metadata["usage"]:
50+
cache_point_usage += 1
51+
52+
agent = Agent(
53+
system_prompt=system_prompt_content,
54+
callback_handler=cache_point_callback_handler,
55+
load_tools_from_directory=False
56+
)
57+
agent("Hello!")
58+
assert cache_point_usage > 0

0 commit comments

Comments
 (0)