|
32 | 32 |
|
33 | 33 | import pytest |
34 | 34 |
|
| 35 | +from nexau.archs.llm.llm_config import LLMConfig |
35 | 36 | from nexau.archs.main_sub.execution.hooks import MiddlewareManager |
36 | 37 | from nexau.archs.main_sub.execution.llm_caller import LLMCaller |
37 | 38 | from nexau.archs.main_sub.execution.model_response import ModelResponse |
@@ -187,6 +188,45 @@ def test_call_llm_success_responses_api(self, mock_openai_client, responses_llm_ |
187 | 188 | ] |
188 | 189 | assert call_kwargs["input"] == expected_input |
189 | 190 | assert call_kwargs["max_output_tokens"] == 120 |
| 191 | + assert call_kwargs["parallel_tool_calls"] is True |
| 192 | + |
| 193 | + def test_call_llm_success_responses_api_honors_parallel_tool_calls_override(self, mock_openai_client, agent_state): |
| 194 | + """Responses API should preserve explicit parallel_tool_calls=False from LLMConfig extra kwargs.""" |
| 195 | + responses_payload = SimpleNamespace( |
| 196 | + output=[ |
| 197 | + { |
| 198 | + "type": "message", |
| 199 | + "role": "assistant", |
| 200 | + "status": "completed", |
| 201 | + "content": [{"type": "output_text", "text": "Hello from responses!"}], |
| 202 | + } |
| 203 | + ], |
| 204 | + output_text="Hello from responses!", |
| 205 | + model="gpt-4o-mini", |
| 206 | + usage=SimpleNamespace(input_tokens=10, output_tokens=5), |
| 207 | + ) |
| 208 | + mock_openai_client.responses.create.return_value = responses_payload |
| 209 | + |
| 210 | + llm_config = LLMConfig( |
| 211 | + model="gpt-4o-mini", |
| 212 | + base_url="https://api.openai.com/v1", |
| 213 | + api_key="test-key", |
| 214 | + temperature=0.1, |
| 215 | + max_tokens=1000, |
| 216 | + api_type="openai_responses", |
| 217 | + parallel_tool_calls=False, |
| 218 | + ) |
| 219 | + caller = LLMCaller( |
| 220 | + openai_client=mock_openai_client, |
| 221 | + llm_config=llm_config, |
| 222 | + ) |
| 223 | + |
| 224 | + messages = [Message.user("Hello")] |
| 225 | + response = caller.call_llm(messages, max_tokens=120, force_stop_reason=AgentStopReason.SUCCESS, agent_state=agent_state) |
| 226 | + |
| 227 | + assert isinstance(response, ModelResponse) |
| 228 | + call_kwargs = mock_openai_client.responses.create.call_args.kwargs |
| 229 | + assert call_kwargs["parallel_tool_calls"] is False |
190 | 230 |
|
191 | 231 | def test_call_llm_responses_api_carries_reasoning(self, mock_openai_client, responses_llm_config, agent_state): |
192 | 232 | """Reasoning items should be preserved for subsequent turns.""" |
|
0 commit comments