Open
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
0.1.5
Python Version
3.13.3
Operating System
macOS 15.4.1
Installation Method
other
Steps to Reproduce
- Add agent that uses OpenAIModel
params = {
"client_args": {
"base_url": "https://mygateway.domain.com/openai/deployments/gpt-4o-mini_mymodel",
"api_key": "...",
"timeout": 60,
"default_query": {
"api-version": "a-particular-version",
},
},
"model_id": "gpt-4o-mini_mymodel",
"params": {
"max_tokens": 1000,
"temperature": 0.7,
"stream": True, # Enable streaming
"stream_options": None, # Use default streaming options
},
}
model = OpenAIModel(**params)
with mcp_server:
# Define the naming agent with tools and a system prompt
mcp_tools = mcp_server.list_tools_sync()
print(f"Available tools: {[tool.tool_name for tool in mcp_tools]}")
naming_agent = Agent(
tools=mcp_tools,
model=model,
system_prompt=SYSTEM_PROMPT
)
# Run the naming agent with the end user's prompt
naming_agent("my new task")
- The response from model have event stream and few of them have empty content array.
- Strands model code errors out when trying to parse openai response in the line https://github.com/strands-agents/sdk-python/blob/main/src/strands/models/openai.py#L97
Expected Behavior
Able to parse response from model and process next steps.
Actual Behavior
Errors out with:
Traceback (most recent call last):
File "/hidden/proto-strands/agent.py", line 56, in <module>
naming_agent("my new task")
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/agent/agent.py", line 335, in __call__
result = self._run_loop(prompt, kwargs)
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/agent/agent.py", line 439, in _run_loop
return self._execute_event_loop_cycle(invocation_callback_handler, kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/agent/agent.py", line 467, in _execute_event_loop_cycle
stop_reason, message, metrics, state = event_loop_cycle(
~~~~~~~~~~~~~~~~^
model=model,
^^^^^^^^^^^^
...<9 lines>...
**kwargs,
^^^^^^^^^
)
^
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 190, in event_loop_cycle
raise e
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 148, in event_loop_cycle
stop_reason, message, usage, metrics, kwargs["request_state"] = stream_messages(
~~~~~~~~~~~~~~~^
model,
^^^^^^
...<4 lines>...
**kwargs,
^^^^^^^^^
)
^
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 340, in stream_messages
return process_stream(chunks, callback_handler, messages, **kwargs)
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 290, in process_stream
for chunk in chunks:
^^^^^^
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/types/models/model.py", line 115, in converse
for event in response:
^^^^^^^^
File "/hidden/proto-strands/.venv/lib/python3.13/site-packages/strands/models/openai.py", line 100, in stream
choice = event.choices[0]
~~~~~~~~~~~~~^^^
IndexError: list index out of range
Additional Context
No response
Possible Solution
No response
Related Issues
No response