Repository: meta-llama/llama-stack
File: src/llama_stack/providers/inline/agents/meta_reference/responses/streaming.py (Python)

Code before:
                    if isinstance(stream_event_or_result, ChatCompletionResult):
                        completion_result_data = stream_event_or_result
                    else:
                        yield stream_event_or_result

                # If violation detected, skip the rest of processing since we already sent refusal
                if self.violation_detected:
                    return

                if not completion_result_data:
                    raise ValueError("Streaming chunk processor failed to return completion data")
                last_completion_result = completion_result_data
                current_response = self._build_chat_completion(completion_result_data)

                (
                    function_tool_calls,
                    non_function_tool_calls,
                    approvals,
                    next_turn_messages,
                ) = self._separate_tool_calls(current_response, messages)

                # add any approval requests required
                for tool_call in approvals:
                    async for evt in self._add_mcp_approval_request(
                        tool_call.function.name, tool_call.function.arguments, output_messages
                    ):
                        yield evt

                # Handle choices with no tool calls
                for choice in current_response.choices:
                    has_tool_calls = (
                        isinstance(choice.message, OpenAIAssistantMessageParam)
                        and choice.message.tool_calls
                        and self.ctx.response_tools
                    )
                    if not has_tool_calls:
                        output_messages.append(
                            await convert_chat_choice_to_response_message(
                                choice,
                                self.citation_files,
                                message_id=completion_result_data.message_item_id,
                            )
                        )

                # Execute tool calls and coordinate results
                async for stream_event in self._coordinate_tool_execution(
                    function_tool_calls,
                    non_function_tool_calls,
                    completion_result_data,
                    output_messages,
                    next_turn_messages,

Review comment (suggestion):
Can you add a test case to verify `top_p` is propagated to /v1/chat/completions, take the following two file as examples:
- https://github.com/llamastack/llama-stack/pull/4775/changes#diff-1b55fd428e0f179b2a4613cf4a38e6669b7437f9d3f3c64b3f92adf9d4d8315a
- https://github.com/llamastack/llama-stack/pull/4775/changes#diff-74c67c4505e934d197765352a3c0eeb655d8deae06e44ece49366b8ea0350523

Code after:
                if allowed_tool_names is not None:
                    effective_tools = [
                        tool
                        for tool in self.ctx.chat_tools
                        if tool.get("function", {}).get("name") in allowed_tool_names
                    ]
                logger.debug(f"calling openai_chat_completion with tools: {effective_tools}")

                logprobs = (
                    True if self.include and ResponseItemInclude.message_output_text_logprobs in self.include else None
                )

                # In OpenAI, parallel_tool_calls is only allowed when 'tools' are specified.
                effective_parallel_tool_calls = (
                    self.parallel_tool_calls if effective_tools is not None and len(effective_tools) > 0 else None
                )

                params = OpenAIChatCompletionRequestWithExtraBody(
                    model=self.ctx.model,
                    messages=messages,
                    # Pydantic models are dict-compatible but mypy treats them as distinct types
                    tools=effective_tools,  # type: ignore[arg-type]
                    tool_choice=chat_tool_choice,
                    stream=True,
                    temperature=self.ctx.temperature,
                    top_p=self.ctx.top_p,
                    response_format=response_format,
                    stream_options={
                        "include_usage": True,
                    },
                    logprobs=logprobs,
                    parallel_tool_calls=effective_parallel_tool_calls,
                    reasoning_effort=self.reasoning.effort if self.reasoning else None,
                    safety_identifier=self.safety_identifier,
                    service_tier=self.service_tier,
                    max_completion_tokens=remaining_output_tokens,
                    prompt_cache_key=self.prompt_cache_key,
                )
                completion_result = await self.inference_api.openai_chat_completion(params)

                # Process streaming chunks and build complete response
                completion_result_data = None
                async for stream_event_or_result in self._process_streaming_chunks(completion_result, output_messages):
                    if isinstance(stream_event_or_result, ChatCompletionResult):
                        completion_result_data = stream_event_or_result
                    else:
                        yield stream_event_or_result

                # If violation detected, skip the rest of processing since we already sent refusal
                if self.violation_detected:
                    return