Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/strands/models/litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ async def stream(

logger.debug("invoking model")
try:
if kwargs.get("stream") is False:
raise ValueError("stream parameter cannot be explicitly set to False")
response = await litellm.acompletion(**self.client_args, **request)
except ContextWindowExceededError as e:
logger.warning("litellm client raised context window overflow")
Expand Down
10 changes: 10 additions & 0 deletions tests/strands/models/test_litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,16 @@ async def test_context_window_maps_to_typed_exception(litellm_acompletion, model
pass


@pytest.mark.asyncio
async def test_stream_raises_error_when_stream_is_false(model):
"""Test that stream raises ValueError when stream parameter is explicitly False."""
messages = [{"role": "user", "content": [{"text": "test"}]}]

with pytest.raises(ValueError, match="stream parameter cannot be explicitly set to False"):
async for _ in model.stream(messages, stream=False):
pass


def test_format_request_messages_with_system_prompt_content():
"""Test format_request_messages with system_prompt_content parameter."""
messages = [{"role": "user", "content": [{"text": "Hello"}]}]
Expand Down
Loading